When in bear country, I prefer to eat somewhere far away from my campsite. One way to do this is to stop somewhere and eat (including washing up and brushing your teeth--toothpaste attracts bears too), and then bike farther before camping. If you do want to cook and/or eat near where you camp, do so a hundred yards from your tent if possible.
I keep all my food and toiletries in one pannier, inside odor-proof bags. If in bear country (which is a small subset of the places you'll be), hang the pannier from a tree a few hundred yards from your tent. If you have some snacks in your handlebar bag, transfer them to the pannier before you hang it. Try to keep your handlebar bag food inside plastic bags so that the smells don't transfer to the bag itself. If you got any food on your clothing, put those clothes in the food pannier as well. If you are cooking, put the clothes you cooked in in the pannier too.
Established campgrounds in bear country often have bear boxes. Those are great and are worth the price of the campground by themselves. Campgrounds in Yellowstone will all have them.
These are all extreme precautions, but are simple to do and give you a bit more margin of safety. Stop at ranger stations along the way and ask if there has been any recent bear activity.
I would not take bear spray. It's not legal everywhere, and you don't want to worry about whether or not it is. Bears will be a concern in the Clearwater National Forest (going over Lolo Pass from Idaho to Montana), in the Beaverhead Deerlodge National Forest (from Ennis Montana to Yellowstone) and in Yellowstone. I don't think they will be a significant concern elsewhere on your route.