Simple rule
Respect the judge and only answer when allowed to speak, stand when allowed to stand, and direct your attention to the judge when he/she is speaking. He was turning his head, looking away, ignoring her, etc.
You aren't at home. You aren't at a football game. You are in a courtroom not mandated by you.
If he would have just behaved in an appropriate manner, none of this would have happened. Conduct yourself in an appropriate manner. If he really wanted to celebrate, a handshake would suffice like most do. Most wait until the judge exits. Sorry, but they have more authority over you in the courtroom.
So the people laughed?
You can't control them either. Your fault for risking causing a scene.
Sad, but true. Always kiss ass to the judge and don't question them.
You never know what type of day they are having, and that's bad for our court system.