Last went to Yellowstone in '18. Saw a gentleman confuse himself with Rambo as he ventured out of the hotel at Mammoth Hot Springs to run across the street to the Post Office....bear spray in one hand, air horn in the other, looking both ways for bear. Knew he was looking both ways for bear because he almost ran into a bison. Sheesh!
If you're not hiking "off-trail", IMNSHO, even if you are, the best bear deterrent is in your head. Being bear aware is better than any other deterrent.
It's super convenient to get bear spray in the park or surrounding communities. I'd second the earlier suggestion...go to a nearby Costco, buy two containers and use one for practice. If you need bear spray, exceptionally unlikely, but if you do, you need to have tried it to know how to use it.