Microsoft 365 features that help users manage their subscriptions, account settings, and billing information.
You cannot do this natively with the 2007 tools. Only way is by doing a Hybrid configuration and creating remote mailboxes.
If you need a script to automate this, just do a search on google/bing, there are lot of examples available. In a nutshell, you need to provision the on-prem user objects (for example, via New-ADUser), set their attributes accordingly (Set-ADUser), then force a dirsync. This part will depend on the tool you are using, for the latest AAD Connect version you can use something like:
Invoke-Command -ComputerName AADConnectServer -ScriptBlock { Start-ADSyncSyncCycle }
You might want to put some delays in the script at that point, using the Start-Sleep cmdlet. 5 mins should be enough, but adjust it to match the size of your org.
Once the accounts are provisioned in O365, you need to set their Usage location and assign licenses. This is done via the WAAD PowerShell module and the Set-Msoluser and Set-MsolUserLicense cmdlets respectively.
If you need it as a bulk script, make sure it takes input from a CSV file or via the pipeline.