Two thoughts:
1. The apex 4-legged predator, the grizzly, is found only in Montana and Idaho. You need a long gun for that one.
2. In the other 46 states, your biggest threat is 2-legged predators. That said, if you ‘re on foot, the weight of your weapon is a consideration. Every ounce counts. My choice among pistols would be a Glock 17 or it’s equivalent from another manufacturer. If concealment was an issue (and it might be on a well traveled trail) then the Glock 19.
You might choose differently, and that’s okay.

Handgun or Pistol Defense Against Bear Attack: 73 cases, 96% Effective
Another ten cases have been added to the cases where pistols or handguns were used in defense against bear attacks. The total now is 73 cases. There were 3 failures. Handguns were 96% effective.
