If you are worried about getting busted in court for a minor possession charge, don't (unless there's more here that you haven't told us about).
First off, courts are not the police. They are two different branches of the government. It seems paradoxical to think this way, but if you confessed to a crime in a court of law, the judge would have to call the cops on you. Note, however, that if you were to be charged later on, the statements you made in court can be used against you. There is no immunity there just because you were a witness in an unrelated case.
Secondly, this is small claims court we're talking about. It's very informal and is by nature a civil court, not a criminal one. Your admission of underage possession on the witness stand might get you a raised eyebrow from the judge, but your criminal activity wouldn't be relevant to the case. He could legally detain you after court and turn you over to the police to be charged, but that would be a serious jerk move on his part. Remember, hearing people's petty squabbles day after day is his job. He's probably seen it all and likely won't care. Just be respectful and dress nicely -- don't give him a reason to care.
Lastly, Minor In Possession (MIP) is a misdemeanor in every state. You cannot go to jail for it (assuming this is your first offense and your record is otherwise clean). Realistically, that's a $100-200 fine at worst depending on where you live. In many cases it'd just be probation depending on the circumstances. And again, that's IF the judge even cares enough to make some example out of you.
Bottom line is, you just have to decide whether your loyalty to your friend and whatever was stolen the is worth the risk. If you're a good person and your nose is (mostly) clean, the risk is pretty low. If there's more to it than what you're saying here, then you'll just have to weigh it out. Or ask more specific questions.