Anyone who writes crime fiction set in the past has to deal with the fact that capital punishment existed. I was surprised to find myself squeamish about this when deciding who my villain would be and how he or she would be discovered.
I'm usually the one arguing that things were different in the past and we must not judge by present day standards.
I don't have a problem with killing characters by other means. I've killed off good characters and bad ones.
There are ways to avoid the issue. Have the villain run in front of a train as he tries to avoid capture; have such strong mitigating circumstances that it can be suggested that the death penalty will almost certainly be commuted (according Old Bailey Online, many death sentences were never carried out); make the villain so irredeemably evil that no-one could feel any sympathy for him; write about crimes that did not carry the death penalty.
But that would feel like cheating (and in the case of the irredeemably evil villain, two-dimensional characterisation). And if one is going to write historical crime, one can't avoid the issue forever.
However I choose to approach it, it must remain my problem and not become my characters'. They are of their time and it's unlikely any of them would object to capital punishment on principle.
If one of them had a personal connection to someone who was facing the drop, however - now that would make a dramatic storyline.