To assign roles to groups, you must create a new security or Microsoft 365 group with the isAssignableToRole property set to true. In the Azure portal, you set the Azure AD roles can be assigned to the group option to Yes.
https://learn.microsoft.com/en-us/azure/active-directory/roles/groups-concept
You can also assign app roles to a security group and the user members of the group will inherit the app roles. You need Azure AD Premium to use this feature. https://learn.microsoft.com/en-us/azure/architecture/multitenant-identity/app-roles