Hello Simone,
As we understand, you need to enable remote mailboxes for the users. The process with require using a business rule and a scheduled task. The rule will trigger After creating a user and mark them (e.g. by setting CustomAtributeBoolean1 to True). The scheduled task will check the mark and whether the user has a mailbox. If the conditions are met, the scheduled task will execute this script from our repository and then clear the mark. You can assign the task only over the members of the groups that are used for assigning Microsoft 365 licenses with access to Exchange Online. Finally, you should have something like the following:
Business rule
Scheduled task