It's not exactly the same thing, but this extension would be the perfect starting point to copy and create a new extension from https://discuss.flarum.org/d/20544-color-circles-for-groups
In fact, if your all your groups of interest have a different color, you might be able to achieve what you want with only CSS and custom selectors based on the values injected by the Color Circles extension (I think the syntax is something like .Avatar[style="border-color:#thevalue"]
)