At least in my last test, such extensions did not work reliably because they do not completely support the special features of the Hugo templates.
Bep had started to develop a corresponding plugin at the end of last year (Template formatter). But according to GitHub - bep/htmlfmt: Work in progress. HTML formatter., development has either been discontinued or is currently paused.