This has been ruled upon. It is perfectly legal & with Trump - advisable
Judges issue gag orders to ensure a fair trial, to facilitate efficient administration of justice, and to prevent prejudicial information from reaching the jury pool.
Gag orders have been used for over 100 years. They have been challenged up to the Supreme Court and have been upheld. In fact in a few cases the Supreme Court itself has used gag orders. I would expect someone who went to law school to know that.