Public (Open Membership) join button adds to role

Hello Everyone,

We are about to launch a public community on our platform. It will be a Group with privacy setting of "Public (Open Membership)".

This will result in a "join" button being shown that a new user has to click to join the community.

This typically adds the member to the group's membership directly.

We would like to instead have the member be added to a role when the join button is clicked (that role being a part of the membership roles on that public group). Is there a way to achieve this?

Thanks,

Mihir