Can outlook365 for mac be installed and connect to an email server via a script? Back in the old days of windows we would use 'roaming profiles' which were very buggy and unreliable but would autoconfigure some network shares and outlook so they could start using any computer. Thankfully we no longer use roaming profiles, or windows - but want to steal some of it's functionality for use on a mac.
I have created a script which (after they login to a share that only they use) connects their required shares, does some shortcuts etc but I would like to configure their outlook365 so they can start using their outlook instantly.
Is there any method that can autoconfigure outlook for me?
Absolutely. Mac administrators script this all the time. Microsoft has employees that are on the mac admin slack and publicly provides training documentation on the preferences that the Outlook app and office suite have for easing on boarding.

https://docs.google.com/spreadsheets/d/1ESX5td0y0OP3jdzZ-C2SItm-TUi-iA_bcHCBvaoCumw/edit#gid=0
https://macadmins.software

If that’s too dry or verbose, you can start with a much nicer package of 25 pages of wiki goodness on setting up Outlook.

https://github.com/talkingmoose/Outlook-Exchange-Setup-5/wiki

I would start small and then iterate, solve little problems first and then get more complete over time as you can save time based on how many machines you are setting up. Also remember, at some point, no automation will save you time if you spend more time learning than just setting up a handful of Macs but conversely, no amount of time will be wasted if you can never set things up manually. You’ll always come out ahead in that case.
This is a well established script and you might be able to adopt someone else’s solution with just a few hours or reading or even less if you already script on macOS.