I needed to add semi-colons to the bash function to get this working for me
modern1 () { osascript -e 'do shell script "sudo killall -HUP mDNSResponder" with administrator privileges'; }
modern2 () { osascript -e 'do shell script "sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder" with administrator privileges'; }