I think you are referring to a moral dilemma like the one proposed by Bernard Williams:
Jim finds himself in the central square of a small South American
town. Tied up against the wall are a row of twenty Indians, most
terrified, a few defiant, in front of them several armed men in
uniform. A heavy man in a sweat-stained khaki shirt turns out to be
the captain in charge and, after a good deal of questioning of Jim
which establishes that he got there by accident while on a botanical
expedition, explains that the Indians are a random group of the
inhabitants who, after recent acts of protest against the government,
are just about to be killed to remind other possible protestors of the
advantages of not protesting. However, since Jim is an honoured
visitor from another land, the captain is happy to offer him a guest’s
privilege of killing one of the Indians himself. If Jim accepts, then as a
special mark of the occasion, the other Indians will be let off. Of
course, if Jim refuses, then there is no special occasion, and Pedro
here will do what he was about to do when Jim arrived, and kill them
all. Jim, with some desperate recollection of schoolboy fiction,
wonders whether if he got hold of a gun, he could hold the captain,
Pedro and the rest of the soldiers to threat, but it is quite clear from
the set-up that nothing of the sort is going to work: any attempt at
that sort of thing will mean that all the Indians will be killed, and
himself. The men against the wall, and the other villagers understand
the situation, and are obviously begging him to accept. What should
he do?
However, it sounds like your example differs from Williams in that this part is not true:
Jim, with some desperate recollection of schoolboy fiction, wonders whether if he got hold of a gun, he could hold the captain, Pedro and the rest of the soldiers to threat, but it is quite clear from the set-up that nothing of the sort is going to work: any attempt at that sort of thing will mean that all the Indians will be killed, and himself.
If that's the case then there is no moral dilemma; clearly killing the captain is the optimal solution. The reason that Williams thinks his version is a true dilemma (and one which utilitarianism gets wrong) is because, in his version, you don't have this easy out.