A non persistent way across reboots to change the DNS:
# scutil
> open
> d.init
> d.add ServerAddresses * 8.8.8.8 9.9.9.9
> set State:/Network/Service/PRIMARY_SERVICE_ID/DNS
> quit
To check the change:
$ scutil --dns
To find a key that we want to change:
$ scutil
> list
...
Other command to change DNS information is:
# networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4