agreed. this has been a major bummer for automation.
the following works:
# in the same conda environment where i normally import arcpy:
import arcgisscripting
arcgisscripting._createGISServerConnectionFile("ADMINISTER_GIS_SERVICES", "C:/admin", "new.ags", "https://maxscoolserver.org/raster", "ARCGIS_SERVER", True, "C:/admin", "sitemanager", "password123")
warning: this is a private method so may not be a great idea, but i'm going to do it until something better comes along.