Shfmt

It uses tabs by default, to use 4 spaces:

shfmt -i 4 script > out
# or to rewrite script in place
shfmt --write -i 4 script

shfmt formats shell programs. If the only argument is a dash (‘-‘) or no arguments are given, standard input will be used. If a given path is a directory, all shell scripts found under that directory will be used.

shfmt --help

man shfmt: https://manpages.debian.org/testing/shfmt/shfmt.1.en.html