Sheriff Andrew Berry took the decision after Brendan Stevens, 21, appeared in the dock wearing the top underneath an open kagool.
He said the clothing was "wholly inappropriate for court".
Mr Stevens, of Thurso, was escorted to the cells below Wick Sheriff Court and later reappeared wearing a plain grey T-shirt.
Solicitor Jo McDonald said: "My client wishes to pass on his sincere apologies."
Ms McDonald said she had not been aware of the motif worn by his client, as he earlier had his jacket zipped up.
Sheriff Berry told Mr Stevens, who denies charges of abusive behaviour and assault: "If you ever come into court dressed in such an inappropriate manner, you will undoubtedly find yourself in contempt. I am prepared to accept your apology, but you should understand I would have been entitled to send you to prison for a year."