@ConradcaThinking about this, I think I've had two 'bad guy trying to kill you' situations (one 'off-page', but the reader knows what happened, and one only partly 'on-page'). In both cases, there was no chance of self-defense. One bad guy later died by firearm. The other did not and is, as best as we know, not dead, and his intended victim would not have wished him dead.
To me, it depends entirely on the characters (who, in turn, depend on the author, obviously). If the character is a strict pacifist, they wouldn't use a firearm even if one was present. Or, if the character was skilled at non-lethal self-defense, they would likely resolve the situation without anyone dying. I suspect most people would find that preferable. Some characters could gun down an assailant and be fine with it. Others would be tortured with guilt for life, even if it was entirely and obviously an 'either them or me' situation.
That doesn't necessarily say anything about the author. If I chose to write a pacifist, and had them pass up lethal self-defense, that wouldn't make me a pacifist (and I am not, in fact, a pacifist). It just means the use of force is incompatible with the story. If I do have any pacifists, though, it's news to me - no one has declared it.
It just feels like a fairly broad question, and one where there are a lot of nuanced answers. Characters should behave consistently with who they are, but there are a wide variety of opinions about lethal self-defense amongst average folks. Why would it be different in fiction?