Depending on your choice of automation (e.g. script, Ansible, Chef, Puppet, etc.), these can be taken from environment variables or files. Since for automation the OneAgent installation requires only one command, the host group is passed during that command so it can be scripted to take that variable from any place.
Without more details about how you plan to automate the deployment, it's difficult to recommend something.
Keep in mind that HostGroup assignment can also be modified after OneAgent installation. This might provide a more flexible option for your deployment needs. https://www.dynatrace.com/support/help/how-to-use-dynatrace/hosts/configuration/organize-your-enviro...