That would be the Killing in Self-Defense[0] trope, mixed with a dash of "Thou Shalt Not Kill[1]". There are many ways to pull this kind of scene of, having the hero kill in self defense preserves the hero's status as "doesn't murder". You can have self-disposing villains[2] so the hero even preserves "doesn't kill" or alternatively you go for "He Who Fights Monsters"[3] (if the hero is corrupted)/"If You Kill Him You Will Be Just Like Him"[4] (corrupted and/or breaking their no-kill rule makes them the villain).
I don't recommend to click the links, TvTropes is a black hole that'll change how you enjoy media forever if you go deep enough.
I don't recommend to click the links, TvTropes is a black hole that'll change how you enjoy media forever if you go deep enough.
[0]: https://tvtropes.org/pmwiki/pmwiki.php/Main/KillingInSelfDef...
[1]: https://tvtropes.org/pmwiki/pmwiki.php/Main/ThouShaltNotKill
[2]: https://tvtropes.org/pmwiki/pmwiki.php/Main/SelfDisposingVil...
[3]: https://tvtropes.org/pmwiki/pmwiki.php/Main/HeWhoFightsMonst...
[4]: https://tvtropes.org/pmwiki/pmwiki.php/Main/IfYouKillHimYouW...