We actually had a very extensive thread on firearms as defense against bears for those who want to research that option:
I personally consider it a last resort with the potential to aggravate the situation, especially when considering pistols.
Since the OP seems to be trying to avoid harming the bear in question though - lots of steps in the middle first, but no argument, it’s a real concern.