Lots of people saying handgun and fair enough, if that option was available to me in Canada I'm sure I would explore it. But as its not, I carry a short barrel shotgun strapped to my backpack as well my rifle. I'm Metis and can hunt year round, so I'm out hunting in the summer when the bears are out and about. I load it with slugs, buckshot as a 'warning' just makes no sense to me, most likely cause of the way I use it. The shotgun comes out once I have an animal down, which is the most dangerous time for a bear interaction. If its coming to challenge me for the meat I have down on the ground it isn't gonna be warned off by buckshot. Even if I could use a pistol, the shotgun seems lie a better tool to me. While actively hunting or trekking, if I encounter a bear, I have bear spray that I'll use (and have used twice) and my rifle as a backup. The main thing to remember is to keep a clean camp site, walk the opposite way of any cubs you see, and steer clear of any kill sites. Other than that, bears are not something to worry about.
I also pee all around my campsite as I heard that will deter them but who knows if thats just BS lol