In recent light of the international coverage of the black bear and cubs on the bridge in Yellowstone National Park, here is a video on how to correctly use bear spray.
The National Park Service highly recommends visitors to Yellowstone carry bear spray. It can be purchased from almost any sporting goods and most grocery stores in Southwest Montana for around $50/ canister. However, it is ILLEGAL to fly with bear spray, both in checked luggage or carry-on.
Another option is to rent bear spray.
There are a couple of reputable businesses that rent bear spray in Bozeman. Phasmid Adventure Rentals, located next to the Bozeman Airport is the first company in the US to rent bear spray and they have an excellent reputation.