Pleading the Fifth
When you are called to the stand to testify, you will hear the prosecutor say something akin to, "the prosecution calls (your name) to the witness stand." Approach the witness stand, which is the box located next to the judge's bench at the head of the courtroom. The bailiff will then ask you if you "swear to tell the truth, the whole truth, and nothing but the truth, under penalty of perjury, so help you God?" Respond with "I do" or "yes," then sit down.
Immediately after sitting, turn to the judge and say, "Your honor, I respectfully invoke my rights under the Fifth Amendment of the U.S. Constitution on the grounds that answering questions may incriminate me." The judge may direct you to provide your full name, to which you should comply.
Answering any other questions will effectively waive your right to take the fifth, and you will then need to answer any additional questions asked of you while on the stand.
Wait until you are excused from the witness stand, then step down and return to the gallery. If you have no other business in court to attend to, you may leave as soon as you are excused.