You could build some sort of trap ranging from simple to Rube Goldberg machine. The complexity of the trap will take time to figure out, and flipping the "lever" or button or whatever to "Release person A!" will automatically "Kill person B!"
For example, there's chasm and a ladder that can cross the chasm. But there's only one ladder. The victims are on the opposite side of the chasm, and there's [thing] charging towards each victim. You can use the ladder to span the chasm, but not in time to let both victims escape.
Perhaps both victims have been critically injured. The priest can save one via spell, but only one in the time allowed before death takes the other. Or poison with one dose of antidote.
Or there's a key to open the cage, but it's made of a fragile material and will break easily -- it's obviously a one-time-use key. Your victims are each in cages... which cage will they open? You will probably want to add some sort of time crunch here, too.
Perhaps there's a super-powerful demon, dragon, lich, etc., standing over the victims with a death spell. It utters a calm "Choose one to live and one to die. Or else I kill them both." The players must choose. The creature grabs the other and vanishes before they can counter-attack. Or kills the other and vanishes, leaving the body.
The above three ideas all involve a countdown to doom. This isn't an accident. Give your players time to think about it, and they will try to come up with a way around your Kobayashi Maru. Players are sneaky that way. You will need to enforce the time constraints on the players as well as their characters.
Also, try to build these traps out From the view of the villain who created them. Why did s/he do so? What's the goal here, from that NPC's perspective? What abilities, tools, time, etc. are at the NPC's disposal? Were they rushed, or patiently working to set this up? Were they trying to build this ethical dilemma, or this is just a side-effect of some other thing they were doing? This will help you build a trap that makes sense within the context of the story.
Also, the previous paragraph will prevent you from making those insanely complex death-traps that only make sense in James Bond movies. That's a subtle way to say, If by some miracle, your PCs find a solution, go with it. If they think of a way to save both NPCs that you didn't plan around, that's okay. Sometimes villains make mistakes. The PCs and the players shouldn't be punished for it if that happens.
Don't forget to play out how the NPC victims are acting in response to the situation. Are they able to beg for their lives? Are they sobbing? In such pain that they cannot communicate? Perhaps one is offering to give up his/her life for the other? They should be active, and if the situation allows, vocal participants in the decision process. (As well as a distraction!)