If you must kill the one to save the many, then ceterus paribus, you kill the one. It's shit, it's always shit, but it's less-shit than not doing it.
And you never, ever pretend that it was actively good. It's not a vector sum. You've still killed someone, the score isn't +9, it's (+10, -1), and those are not the same thing. You bear the blood on your hands forever, you accept the mantle of killer and you do it anyway. That's a shit deal, but life throws you shit deals. If you ever try to paint yourself the hero for it, you're a killer and a fucking coward.
Kid going for a nuclear bomb trigger disguised as a teddy bear, you're 250 meters away and only have a sniper rifle: sorry honey, :bang:
You may have saved the city, but you still killed a kid, and you're supposed to feel shit about that. And if you don't, something is very very wrong with you.
But ceterus is rarely paribus, is the problem. Couching the problem in this particular formulation robs the problem of its purity, and now you're tying in externalities like what happens to your society when you put the force of law behind decisions like this - and whether there are knock-on effects that skew the balance.
What you've got here is a hostage situation with extra steps. They're ill-defined hostages with no specific identity or location, which prevents you from just sending in a SWAT team, and that gives you a clear choice: capitulate with their demands, or sacrifice the hostages outright.
For an individual to capitulate is likely the better choice, as they aren't likely to be in this situation again, and a one-off less-worse situation beats the alternative.
But for an institution like the justice system to capitulate is pretty much guaranteed to be the worse choice, as they're going to be involved in the great majority of hostage situations going forward, and a reputation for capitulating will invite many, many more such cases. That anticipated harm can easily be expected to far outweigh the harm of sacrificing one set of hostages, and so the only reasonable choice, shit though it is, is to be a hardass about them and sacrifice them.