You can get very basic provisions in Cooke City at one of the gas stations or at the general stores in Cooke City and Silver Gate. (The general stores are only open seasonally—typically June through October.)
During the warmer season (typically June throught October), the nearest grocery store is in Cody, WY (~80 miles / 1.5-hour drive) over the Chief Joseph Pass. You can also get to a grocery store in Red Lodge, MT (~110 miles / 2-hour drive) over the Beartooth Highway.
During the colder season (typically November through May, when all other routes are closed), the closest grocery store is in Gardiner, MT (52 miles / 1.5-hour drive) through Yellowstone National Park. (Keep in mind that driving through YNP can often take longer than expected due to traffic and wildlife.)
This information is dependent on season, weather, and road closures, so be sure to plan ahead if you are wanting to access the nearest grocery store!