When I was practicing law, courts were open to the public, and remained so, except in statutorily provided instances [child rape victim, unless closed circuit TV could be used], undercover cops still working undercover [and that required a hearing], or upon motion [in VERY limited circumstances] by counsel, with both sides heard [subject to Court action by the media if the courtroom was sealed].
I can't remember more than three or four times in 26 years that happened. I never heard of a case, or saw one where the judge, sua sponte] sealed the courtroom himself.
The judge wasn’t conducting a court proceeding, so there was no constitutional violation. He was giving a speech to a group of people.
As for me, I think the guy did the right thing.