germany
Exactly that happened in a spectacular case in 2002 which was widely discussed. The setting resembled the basic premise of the TV series 24: How far can — or must! — a policeman go to prevent a tragedy when time runs out?
In this concrete case, a man abducted a child of a rich family and tried to blackmail them. He was soon apprehended and refused to disclose the location of the boy. In order to locate the child and potentially save his life, the Frankfurt police chief ordered a subordinate to threaten the perpetrator with torture, which he did. In the end, the boy had long been dead; but the torture threat had a legal aftermath.
Torture, including its threat, is directly forbidden by Art. 1 GG which famously guarantees that "human dignity shall be inviolable. To respect and protect it shall be the duty of all state authority." Criminally, it falls under §240 StGB as coercion (Nötigung), with stricter minimum sentences if performed by government officials. Both the subordinate and the chief were charged, with coercion resp. instigating coercion in an official function.
The decision and sentence is remarkable. For the sake of this discussion I want to focus on the fact that the court, even though it considered the defendants guilty, sentenced them only to a monetary fine, below the minimum prescribed by the law (for a government official, the minimal sentence would be 6 months in prison for the subordinate). That sentence then was suspended, on condition of a one year probation period. The court justified this with the massively mitigating circumstances. In effect, the policemen were not punished at all even though the court made clear that they were guilty as charged.—
Another, less spectacular possibility is
§60 StGB which says (emphasis mine):
Das Gericht sieht von Strafe ab, wenn die Folgen der Tat, die den Täter getroffen haben, so schwer sind, daß die Verhängung einer Strafe offensichtlich verfehlt wäre. Dies gilt nicht, wenn der Täter für die Tat eine Freiheitsstrafe von mehr als einem Jahr verwirkt hat.
Deepl translates this (and I agree) as:
The court will refrain from imposing a penalty if the consequences of the crime that have affected the offender are so severe that imposing a penalty would be clearly inappropriate. This does not apply if the offender has incurred a prison sentence of more than one year for the crime.
Trish had a better example than I did originally: In a car accident caused by negligence a bystander is injured, which constitutes bodily harm caused by negligence. But in the same accident, the culprit is crippled for life. The law considers that punishment enough.
Note that this is not optional but binding; the purpose of the law is not retribution.
This last topic is not about a trial; instead, in Germany the paradox of a criminal act that can nonetheless be committed with impunity is even part of the criminal code. It is the way in which the government tried to square the circle regarding abortion.
After the reunification with the GDR in which abortion during the first 12 weeks had been legalized in 1972 (the only law ever which had opposing votes in parliament), the "unified" (in fact West German) law was changed to include essentially the same provision. The conservative state of Bavaria, outvoted in the legislative process, called upon the Constitutional Court for redress. The court stated that the constitution demands the protection of all human life, including the unborn, and declared the law unconstitutional. In response, the parliament changed the wording of the $218a from "the abortion is not unlawful" to "the offense has not been committed" (der Tatbestand [...] ist nicht verwirklicht).
This contorted wording apparently satisfies the Constitutional Court's demand that the state protect the unborn life. The effect is that abortion under certain conditions is still unlawful but not punishable, exactly the split you asked for, albeit legislatively, not jurisdictionally.