I think Buddhist philosophy allows a simple answer to this question. It's all about Intention. In ignorance and delusion we constantly cause suffering to ourselves and others. Not being omniscient, there's no way we can know exactly what effects any given action will have--that's why we follow the N8P to develop our morality, concentration and wisdom, and reduce the amount of suffering we cause.
The scenarios of the train and the killer are contrived and don't allow for tricks like pulling a lever halfway, or talking the killer out of out of it or just shooting him in the kneecap. It comes down to a math problem since the only variable is the number of people killed as a result of our choice. Basically what the scenarios are designed to do is show the difference in our emotional response to causing death directly (the killer) or indirectly (the train).
When we can look at it from a Buddhist perspective, it still works as a math problem, considering our best intention is to reduce suffering. With the train I would pull the lever to kill the least number of people and would be acting out of my best intention. Standing by and doing nothing out of fear of doing the wrong thing would be a less skillful action.
With the killer, again it would be a better intention to save the victims from death and their families from suffering pain and possibly developing hate and desiring revenge, as well as stopping the killer from suffering the kamma of killing them. Of course you would still cause suffering to the killer and those who care about him/her, but it would be less, like the one versus five in the train example.
Usually killing comes out of hate and anger, but in these scenarios you wouldn't be killing out of hate but of out of the intention to reduce the amount of suffering.