If you want to convert a mailbox to shared to preserve it, but you want to disable or delete the AD account, do the following-
- Go into mailboxes in Exchange Admin Center, click "Convert to Shared" on the right.
- To to the users in Microsoft 365, remove the users license.
- Disable or delete the AD account, wait for Azure AD to sync.
- Under Admin Centers, click Azure Active Directory, Users, Deleted Users. Select the users and click "Restore Users." This will move them to a "Cloud User" which will need to be maintained to prevent the mailbox from being deleted. This account will not be able to log into the mailbox, however, so it presents a pretty minimal risk. You can set a complex password and enable MFA.