This is something that I constantly run into. I don't talk much, especially in large groups, so there will often come a time when I want to leave, but don't know how to do so. I can think of two options:
Enter/interrupt the conversation to notify everyone that I am leaving. This seems rude and selfish, if I wasn't a contributing part of the conversation then why should I interrupt it to talk about myself, especially if it's just to say I will not be making any future contributions?
Simply walk away. This also seems rude, as it doesn't give people the chance to say goodbye, and/or complete any tasks that require my attendance.
What I end up doing most of the time is a sort of "I'm leaving now" dance, where I look at my phone to see what time it is a few times, then make a fuss of gathering up my things, then back up a bit or start standing closer to the door, before simply walking out. This feels stupid, inefficient, and identical to option 2 if people don't notice me.
To clarify: the people in these 'groups' are usually individuals I would consider acquaintances more than friends. Like people I have been working with or taking a class with for a few months or so. Generally not people I hang out with outside of whatever event put me in the situation described above. The topic of conversation is informal, and I need nothing more from anyone, but am unsure if they would need anything from me.
For example, I take longsword classes. After the class is over, people stand around and talk, usually about longsword-related subjects. I stick around to listen, but sometimes I have other places to be, so I want to leave. During these conversations I have either said nothing or have not said anything for some time. None of these people are people I hang out with outside of the class.