When this approach has been tried in real life, however, it hasn't ended well. In 1871, Clement Vallandigham was tasked with exonerating a local man from the charge of having blown someone away during a bar brawl. It seemed like a cut-and-dried case of murder until Vallandigham got all CSI on their asses. Using a rudimentary experiment, he was able to prove that the victim shot himself while pulling out a gun (presumably to do some murdering of his own). When the time came to demonstrate this, Vallandigham imitated the victim with perfect accuracy ... including the part where he shot himself.
The legal term for this is "habeas corpus."
In his haste to prepare for court, Vallandigham had picked up the wrong revolver. Instead of the empty revolver specially purchased for court, he'd chosen the loaded revolver he'd used in his experiments. According to accounts, Vallandigham lasted a heroic 12 hours before expiring from a combination of shock, blood loss, and just, like, the worst case of embarrassment. And, as it'd be dumb otherwise, his client also went free.