How can I turn on the macOS firewall from a script
macOS now uses the pf firewall (from OpenBSD).  Since Mac OS X Lion (10.7) circa 2012, the firewall ipfw was deprecated in favor of pf 

The command to disable the pf firewall is:

% sudo pfctl -d 


For full command line options for pfctl see man pfctl.