Prettier is an opinionated code formatter, has built-in a lot of code formatters for languages, one of that is for handlebars (glimmer/mustache) but is hidden by default, to enable we only need to do this:

create a .prettierrc in your home (~) with :

{
  "overrides": [
    {
      "files": "*.hbs",
      "options": {
        "parser": "glimmer"
        // ... other custom configurations
      }
    }
  ]
}

and now you can use in your favorite editor or simple use directly with the CLI, for example:

prettier --write "**/*.hbs"

Know more of configuration prettier

An example of .prettierrc config file