Hello KCM,
Currently there's no built-in method to detect UTM zone based on the Lat/Long values, so if you need to do it automatically, then custom function will be required. I haven't checked, if your code works, but if it has any problems, please let me know and I'll try to suggest another approach.
Something like that seems a bit easier:
def get_utm_epsg(lon, lat):
zone = int((long + 180) / 6)
if lat > 0:
epsg = 32601 + zone
else:
epsg = 32701 + zone
return Metashape.CoordinateSystem("EPSG::"+epsg)