The script is wrong in some places.
# ===============================================================================
# Enable NXDOMAIN response for blocked domains
echo "BLOCKINGMODE=NXDOMAIN" | sudo tee /etc/pihole/pihole-FTL.conf
That will add an additional line to the config file and that is not correct. If you want to change the mode then you need to sed in changes to the existing mode configuration line. If it doesn't exist then you add it.
Same as with
echo "IGNORE_LOCALHOST=yes" >> /etc/pihole/pihole-FTL.conf