How to Configure Google DNS or OpenDNS with Netplan?

I’ve tried setting up OpenDNS with netplan via the following two methods. And they don’t work. I know because I issue the command sudo netplan try and I get an error.

method 1

sudo vi /etc/netplan/50-cloud-init.yaml # Put this in the body nameservers:      addresses: [208.67.222.222, 208.67.220.220] # Save, exit, then `sudo netplan try` 

…or this. Note that my internet is WiFi, not ethernet, not sure if that’s the issue with my syntax.

method 2

sudo vi /etc/netplan/50-cloud-init.yaml # Put this in the body network:   ethernet:     wlo1:       nameservers:         addresses: [208.67.222.222, 208.67.220.220] # Save, exit, then `sudo netplan try` 

How do I setup OpenDNS with netplan? I know my link right here explains it, but that’s for older Ubuntu and doesn’t work anymore. I can’t even open Network Connections on Ubuntu 18.04. I think Network Connections GUI is deprecated.