I think the general view is that is forbidden to flip a switch to cause the death of 1 person to prevent 5 other people from dying. Judaism does not just take the utilitarian view to just look at the ends and ignore the means involved, especially when dealing with committing a sin such as murder. (See Does the end justify the means.) Therefore it would be better to "shev v'al ta'aseh" rather than commit an act of murder. After all "mai chazis" that the 5 people's lives are more valuable than the one person's life? (See Pesachim p. 25) You are not God to be able to make such judgements.
I think this would hold true even if it was only a case of grama and one would not be liable for the death penalty for killing the person. The accepted halacha holds that the 3 cardinal sins are "yehareg v'al ya'avor" even when they are just "abuzraya". Therefore even though one would only be committing an abuzraya of murder, it would still not be allowed.
The case in Yerushalmi and Tosefta on Terumah (which the Rambam in Yesodei haTorah is based on) are discussing a much more complicated case involving enemies and betrayal, uncertain results, and the death of the person in question either way. Therfore I do not know how easily it could be applied to this case.
As for a shooting down a hijacked plane, R' Bleich just published an article in Traditon on this topic which forbids it, which I'm sure quotes many more sources. His view is summarized by R' Broyde:
Rabbi Bleich's essay represents his view that the sanctity of innocent
life - not in wartime - is very profound. Many other halachic
authorities adopt the view that at least in wartime one certainly can
kill innocent people to save the lives of the multitudes.
Unless one can somehow consider the entire plane to have a din of a rodef, it seems difficult that one can say we can directly go and kill everyone on the plane beforehand (although the fact that they will die soon anyways does make it different than the trolley case) . R' Broyde seems to say that different rules apply during war, but I would normally assume this applies to enemy civilians, not captives.