Given that we presume someone dies either way it becomes murder or manslaughter -- it's kinda hard to be involved in someone dying without those charges being discussed -- but that gets very much into the weeds of jurisdiction specific laws and I'm not super familiar with them.
What is very interesting to think about is tort law, the general case history of negligence and liability when one person harms another but it isn't explicitly illegal. Basically the injured person or family sues someone for doing something they shouldn't have, and it gets into really interesting weird cases like could they have reasonably foreseen the injury etc. Here's a summary of some major tort precedents going back many years: https://www.findlaw.com/legalblogs/greedy-associates/5-classic-torts-cases-made-simple-for-1ls/
My favorite is Palsgraf v. Long Island Railroad Co. (1928) where a Rube Goldberg style chain of events caused Mrs. Palsgraf to be injured and it was ruled that the rail employee could not have reasonably foreseen all of that, so they weren't liable. If anything (in my opinion) the men who brought fireworks in an unlabeled container onto a train and then ran to catch it were the ones behaving negligently (i.e., the originators of the foreseeably dangerous situation.)
This is a long way of saying, if you do nothing then you're an innocent bystander to a tragedy. But if you take an action that reasonably (in this case certainly) causes injury, you're responsible for that. You might say you'd rather have one man's death on your conscience than a dozen, but that's for you to meditate on in jail.
The real problem with the Trolley Problem is that it presupposes only two outcomes. In real life we don't know what the possibilities will be and many actions are available to many people. First and foremost whoever tied the people to the tracks needs to be found and tried. Second, the trolley driver and whoever created, installed, or maintained the brakes needs to be interrogated. (Trolleys don't generally drive very fast and they almost always have low bumpers to prevent things from falling underneath.) Finally, a number of other things had to go wrong or fail to go right in order to get into the situation: the tied people have to remain there for awhile unnoticed or unhelped by anyone until it's too late, the trolley has to not notice things and be traveling too fast to slow down by other means, and every human between the people and trolley has to essentially freeze and fail to do extreme things like cut the power or derail the trolley or yell at someone for help. There are almost always third fourth and fifth options besides a singular person happening to stand by a singular track switch that points to certain death either way.
If it was me, I would yell for help and get myself and one other to man the switch and untie the single prisoner simultaneously. Even if we somehow fail, that action is more natural and moral and understandable to a jury than freezing up and choosing only the second worst option.
Ultimately it boils down to the jury, the judge's instructions, and the specific wording of the law.
If we take Washington DC as an example, the lowest illegal killing law is involuntary misdemeanor manslaughter, like if you do something illegal and someone dies even if you didn't intend it. It requires:
- Defendant caused the death of the victim;
- Defendant did so while committing or attempting to commit an underlying misdemeanor; and
- Defendant committed or attempted to commit the underlying misdemeanor in a manner that created a reasonably foreseeable risk of appreciable physical injury.
So then you get into whether touching the rail switch was a misdemeanor or not (what are the laws on touching railroad stuff) and who in this unlikely chain "caused" the death. Once again we get into "foreseeable" despite the problem assuming that one person's death is guaranteed, which isn't actually how reality works.
https://www.findlaw.com/state/dc-law/district-of-columbia-involuntary-manslaughter-laws.html
Ironically, placing objects upon a railway with intent to cause harm OR doing something that "displaces or injures anything" related to the railroad resulting in death, is murder in the first degree in DC. So if throwing a switch counts as displacing a rail-related thing, which it probably does, the D.A. could try and get you for the worst form of murder they have. After all, in the real world you have no idea how trolleys and rail switches work. The problem supposes that you have perfect knowledge and awareness of many things, with the huge omissions of not noticing until it's too late and only having one possible action to take. I might add that trolleys often don't have switches laying around (they tend to take fixed paths) and when they do they're not immediately accessible: they're usually actuated by a separate tool or electric signal that the public doesn't have. If we're talking about a full sized railway then those levers are big and hanging around, but it's illegal to trespass onto the rails and switching yards are placed far from the public. But anyway all of this depends largely on how the D.A. is feeling, which is bad news because most D.A.s are elected officials who politically campaign on seeming tough. So do people see you as a sympathetic everyman, or a contemptible fuckup, and how's the D.A.'s career going? https://code.dccouncil.gov/us/dc/council/code/sections/22-2102
If you can afford a decent lawyer, though, they'll definitely request a trial by jury and play up the fact that you were doing your best to save as many people as you could in an awful situation set in motion by some other psychopath. Make sure to look mournful yet sympathetic to the jury. If you're a white conservative Christian man with young kids in America, even better.