First. Make sure everyone in your group understands that this is a no win situation. I feel like if they know they cannot win from the outset they will not be too disappointed whenever what they try does not work, at least to the full extent they were hoping it would. This does not have to be stated out right, it can be more subtle, but I feel like at least a hint of this should be there.

Second. Design your situation so that success does have some kind of effect. Could a persuasive argument lessen the sentence? Could they convince the court that instead of a maximum security prison the convicted player should go to a prison where he can be more easily rescued? I would make it so that if your players rolled/RP'd well enough there was some sense of accomplishment even if the overall mission will inevitably be a failure.

Hopefully the understanding that this is a somewhat on rails plot and back story building should lead to fairly cooperative players.

Finally, have a backup plan. If all of this goes to hell leave yourself a way out. Maybe this is only the first time the PC gets wrongfully accused. If somehow the players manage to change the outcome of the trial then let them continue on but look for a new opportunity to wrongfully accuse/imprison the PC a second time or approximate it in some way that fits the backstory...It might feel a bit railroady, but if you've warned them ahead of time it should be OK.