Via Windows Image:
Download Office Deployment Tool to server share (\\Server\Office365$ for example) from microsoft download centre:
https://www.microsoft.com/en-us/download/details.aspx?id=49117
Copy and edit existing configuration profile or create a new deployment configuration profile with required settings.
https://config.office.com/officeSettings/configurations
Most Importantly, make sure to change the install location Source path and the Update path:
Once you have a deployment configuration profile, go back to the \\Server\Office365$ share you created and extract the setup.exe and other files. Copy the config profile here and edit the last line:
<Display Level="None" AcceptEULA="TRUE" />
This will prevent office from trying to activate before you can sysprep and create the Windows Image. When you're ready to install run the following command:
.\setup.exe /download .\configprofile.xml
That will download the required install files for your config profile. Once downloaded, go to your windows image and run
.\setup.exe /configure .\configprofile.xml
That will install office with your specified settings from the config profile.
Do not sign into office once installed. You can now sysprep and create the windows image.
Via SCCM Task sequence
Using the config XML and server share created above, you can deploy 365 at the end of your SCCM task sequence:
This will then install after a computer has been imaged