The overwhelming majority of defendants follow their lawyer's advice to not talk about the case. Even if they are convinced that the case is unfair and improperly motivated, they stay quiet because their lawyers tell them that is the best way to win an acquital.
So people get the idea that it is somehow illegal for a defendant to speak out, instead of letting his "mouthpiece" do the talking. Lots of lawyers would like it to be illegal, so they could make more money speaking for their clients.
It isn't.
It is not only not illegal to speak out when government is unfair and corrupt, doing so is a right enshrined in the very first amendment in the Bill of Rights. People thinking it is illegal because it is rarely done is a perfect example of rights being weakened by not being exercised.
I can fully understand why the judge would want to silence Trump from talking about how the judge's family profits from promoting Democrat politicians, and I can understand why Michael Cohen likes being free to slandar Trump and would prefer Trump not be allowed to respond. But that isn't the country we are. Not yet anyway.
We count on judge's to uphold our rights, not to trample them as Merchan is trying to do. I'm glad Trump is not rolling over for him. He not only has a right to speak, the voters have a right to hear, and one Canadian-looking New York judge doesn't have the power to take those rights away.