As you know, if your Teams administrator has allowed anonymous users to join a meeting, these anonymous participants can use the Teams chat feature to interact with others.
Well, this chat access can potentially lead to data exfiltration.
To continue allowing anonymous users to join a Teams meeting but lock down the access to the chat, a new setting is available to enable chat for everyone but anonymous users.
You can set it from the Teams administration portal (https://admin.teams.microsoft.com/) under the Meeting engagement section of the policy from the Meetings\Meeting policies
You can also do such thing using Teams PowerShell with the below command
Set-CsTeamsMeetingPolicy -Identity <policy identity> -MeetingChatEnabledType EnabledExceptAnonymous