For now Microsoft has only provided a way to migrate from distribution lists to Groups but not from Shared mailboxes to Groups.
Here is a similar question for your reference:
https://techcommunity.microsoft.com/t5/microsoft-365-groups/migrating-shared-mailbox-to-o365-group/m-p/30068
You could use some third party tools to migrate Shared mailbox into the o365 groups:
https://www.nucleustechnologies.com/supportcenter/kb/migrate-office-365-shared-mailbox-to-office-365-group
Note:
Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.