There are occasionally times when laughing out loud in court is okay, but they are all too rare. Importantly, the odds that it is okay to do this go way down if you are the only one laughing.
A station in Fayetteville, N.C. reports that a judge became irritated on Friday after a man began laughing in her courtroom and refused to say why. Judge Toni King eventually ordered the man arrested on "a misdemeanor charge" that was almost certainly contempt of court. As he then learned, once you are under arrest the police will search you. Turns out that what was funny was that he had three grams of crack in his possession. And probably a little more in his system.
The man was charged with felony drug possession, which under the circumstances was probably also briefly hilarious.