Let us do all that work for you and just lean back...
Synchronize contacts with Microsoft 365 (shared mailbox)
From now on, not only personal Microsoft 365 contacts can be synchronized, but also those of shared mailboxes. Since these do not have their own credentials, the connection is established via a corresponding Microsoft 365 user with access rights to this mailbox. The shared Microsoft 365 mailbox can be used as a sync source or target.