Super Contributor
How Block users from Sharing files in Teams?

Teams leverages SharePoint/OneDrive for the file sharing experience, so adjust the corresponding sharing settings in SPO/ODFB.

To be specific, you can use the modern SPO Admin Center to adjust the sharing setting for any Teams site and then in each site itself you can do also some adjustments in the security and permissions

@Juan Carlos González Martín Can this be applied to a user group?

Good News !! =). you can do that.
for current users: need to delete the SharePoint site and unassign the licenses.
for new users: unassigned the licenses
follow the article for full step-by-step details...