The judge didn't say "no show of emotion" for nothing. I infer that there had been warnings about previous "non-verbal gestures and outbursts" throughout the trial. I'll bet the judge was very tired of disruptions.
I don't think it has a thing to do with "thanking Jesus". It has everything to do with maintaining order in a court of law. Judges maintain order by restricting sound and motion; nothing prohibited the defendent from closing his eyes and saying a silent prayer of thanks, for example. It was disobedience, not the particular words, that got him in trouble.
Think about it -- defendents get in trouble for disruptive outbursts all the time, typically having nothing to do with Jesus. If this were a leftist claiming victimhood, we'd be jumping up and down on him. If it was a Muslim who shouted "allahu akabar", we'd want to string him up for disrespect. This time the defendent happens to "Thank Jesus", and we're all sympathetic? Sheesh, must be a slow news day.
But at the point where he was aquitted the trial was effectively over and then there's the no small matter of the judge not letting him simply apologise and leave. Instead he locks him up in jail after there is no more trial to disrupt.