I spend a lot of time studying in coffee shops, and I enjoy the occasional break from my books by eavesdropping on people at nearby tables. The other day, I overheard two women having a very lengthy conversation about dating, studying, Judaism, new restaurants and many more topics that defininitely caught my attention. At more than one point during their conversation, I realized they were actually talking about people I know. They weren't saying anything bad or even necessarily what could be considered gossip, but it was still weird to listen without letting them know that I knew who they were talking about. They even asked a question about what one of these people was studying, and I knew the answer but resisted butting in. Was there an appropriate way for me to let them know I was in a similar academic circle, or was I right to keep my mouth shut?
What fun! Sounds like you got a juicy earful without even having to toe the line of lashon hara , the Jewish term for gossip. Translated as "evil speech," or "bad tongue," lashon hara refers to sharing negative statements about someone even if they're true. If you heard someone speaking negatively about someone you didn't know, depending on the other circumstances, I'd probably tell you to stay out of it. If you heard someone speaking negatively about someone you did know, I would advise you to say something along the lines of, "I'm sorry to interrupt, but I'm uncomfortable overhearing this conversation." You could leave it at that or add, "about someone I know," to the end of that sentence. In the Jewish legal aspect of things, you don't want to be an accomplice to lashon hara, and in the good person moral secular aspect, you don't want to hear someone badmouth people you respect. If you dislike the people in question, well, maybe you would enjoy hearing them slandered, but I'll leave that up to you.
Alas, this was not your question. You want to know if you should have told these strangers saying innocuous things about people you know that you knew who they were talking about. Was there some small part of you waiting to hear something negative or gossipy? Were you afraid that if you told them, they'd think you were creepy and they wouldn't feel comfortable to continue their conversation, however innocuous? Regardless of what you were thinking or hoping to hear, you're not under any obligation to "out" yourself to strangers in a coffee shop. They knew they were in public and that the people around them could very well be listening. Maybe they were on especially good behavior as a result, and that's why you didn't hear anything negative. Or maybe they were just good people, sharing information about classmates totally devoid of malice. How refreshing and unusual to overhear a conversation that didn't make you question the moral fabric of our society!
If you had wanted to join in their conversation, you could have said something like, "I'm sory to interrupt, but I can't help hearing you talk about Sarah. Do you go to school with her? I'm studying X, and I know her from Y." You've entered into their world, but you haven't forced them to include you. You've given them (and yourself!) the option to meet some new people with presumably common interests and mutual friends. Coffee shops at their very best operate as a "third place"  and provide customers with the opportunity to interact with friends and neighbors who they wouldn't otherwise encounter on a daily basis.
All that being said, if this experience made you uncomfortable, next time you're having a conversation in a public place, maybe, for better or worse, you'll think more carefully about what you're saying and who might be listening. In the world of cell phones, it's hard to remember that people can hear you, and sometimes the private does become public. If you felt weird hearing this conversation about people you know, maybe you'll find a way to avoid putting other people in a similar situation. Not talking about people is extraordinarily difficult, sometimes impossible. But once you're talking about someone, it's easy for someone else to hear and interpret and possibly misinterpret. All things considered, it sounds like no harm came from this particular encounter, and maybe it's time to invest in earphones for future study sessions.