I occasionally ride with strangers. Sometimes it's a verbal "hey do you mind if I hop on for a bit?" and sometimes it's just a non-verbal situation where I get swallowed up by (or catch up with) a larger group and just start riding with them. This is definitely a "read the room" situation, and I've never had people tell me that I couldn't ride with them, but also there are times when it's obvious to me that a group doesn't want random people hopping on. If you're not sure, ask.
I think the smaller the group, the more important a verbal conversation is. It definitely seems weird and a bit rude to just start riding right behind a solo or small group of riders without saying anything. If your intention is to just ride behind a group at a safe distance to see if you can hold their pace, there's really no need to ask. If you're closer than 2-3 bike lengths for more than a few minutes, it's probably time to either join the group, pass or drop back.
A question for the OP: It sounds like you're interested in finding a local group ride to join. I would expect any organized group of kitted roadies to be a bit suspicious of someone wearing street clothes/shoes and riding an old MTB randomly hopping into their ride mid-way, even if you ask and can hold the pace. You'd likely get a much better reception if you show up at the start.