On many Ubuntu server images, /etc/netplan/50-cloud-init.yaml is written by cloud-init. Edit it by hand and your change can disappear later.
I switch off the network part of cloud-init with a file of its own:
echo 'network: {config: disabled}' | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
From then on cloud-init leaves the network alone, while the rest of it keeps working. Now copy the generated file to a name that is yours and edit that one:
sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/60-local.yaml
sudo rm /etc/netplan/50-cloud-init.yaml
sudo chmod 600 /etc/netplan/60-local.yaml
sudo netplan generate
Removing the old file avoids two files describing the same interface, which gets confusing fast. Check with generate that the YAML still parses before you reboot.
Careful on a cloud VM: some providers change network details through cloud-init, for instance when you add a second address or resize the machine. With it disabled, that stops happening and you have to edit the file yourself. Keep a serial or web console at hand, since a mistake here can cut your only way in.
Further reading: cloud-init network configuration