Recently I had the issue in a Symfony project that my <script> code was not formatted correctly in .html.twig files using vscode-twig-language-2 formatter.
Searching for an existing issue or hint on configuration I found this issue. The comment by @ianshea did the trick as workaround!
<!-- parse-ignore-start --> + <!-- parse-ignore-end --> excludes the part from formatting entirely.
Hopefully one day the formatter will also be able to handle scripts formatting itself.