If the circumstances force you into the kind of contact that makes it awkward not to react, a simple momentary nondescript nod and half-smile will suffice. No talk. No "watching." Avoid the need for even the nod if possible. Do not be surprised if the judge does not appear to recognize you and does not react.
My responses to questions on Avvo are never intended as legal advice and must not be relied upon as legal advice. I give legal advice only in the course of an attorney-client relationship. Exchange of information through Avvo's Questions forum does not establish an attorney-client relationship with me. That relationship is established only by individual consultation and execution of a written agreement for legal services.