Yes, you can use a lava badge to accomplish this.
It would be a badge with Entity Type- person; Badge Type-Lava.
In the Display Text place this lava then set Group Type to match your groups: (lava written by Mark Lee)
{% assign person = Person %}
{% sql personid:'{{person.Id | Default:0 }}' %}
SELECT
g.Name as GroupName,
g.Id as GroupId,
g.IsArchived as GroupIsArchived,
gm.IsArchived as MemberIsArchived
FROM GroupMember gm
JOIN [Group] g on g.Id = gm.GroupId
WHERE gm.PersonId = @personid
AND gm.GroupTypeId = 43
ORDER BY g.CreatedDateTime desc
{% endsql %}
{% assign size = results | Size %}
{% if size > 0 %}
{% assign isActive = results | Where:'MemberIsArchived', 0 | Size %}
{% if isActive > 0 %}
{% assign color="#207FB9" %}
{% else %}
{% assign color="#464646" %}
{% endif %}
{% else %}
{% assign color="#cdeff8" %}
{% endif %}
<div class="rockbadge rockbadge-icon"
style="color:{{color}}"
{% if size > 0 %}
data-toggle="tooltip"
data-html="true"
data-trigger="hover focus click"
data-placement="bottom"
title="
<div>
{% for item in results %}
<a href='https://admin.ccl.network/people/groups?GroupId={{item.GroupId}}' class='text-white' >
{% if item.MemberIsArchived or item.GroupIsArchived %}
{{ Person.NickName }} is in former cohort {{ item.GroupName }}
{% else %}
{{ Person.NickName }} is in active cohort {{ item.GroupName }}
{% endif %}
</a>
{% if forloop.last == false %}
<hr style='margin:5px;'>
{% endif %}
{% endfor %}
</div>"
{% endif %}>
<i class="badge-icon fa fa-user-friends"></i>
</div>