import xml.etree.ElementTree as ET
tree = ET.parse('input.xml')
ET.indent(tree, space=' ')
tree.write('output.xml', encoding='UTF-8', xml_declaration=True)
python3.9からElementTreeにindent関数が追加されている
https://docs.python.org/ja/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.indent