I've been automating this stuff for years. There is a new (something?) in play during the homebrew install.
I had the same error as above, I filed the issue and got a response that fixed my problem:
CI=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
I'm not sure what prefixing with CI=1 does but all of my automation issues went away.
I hope this helps.