Most ufw rules guard the way in. The same syntax works for traffic leaving your server, which helps when a box must never talk to a certain network.
Add out after the action and give a destination:
sudo ufw deny out to 203.0.113.0/24
sudo ufw deny out on eth0 to 192.0.2.0/24 port 445 proto tcp
sudo ufw status numbered
The first rule blocks everything from this server to that network. The second is narrower: no SMB to one subnet, and only through eth0. In the status output these rules carry OUT so you can tell them apart from incoming rules.
I think this suits a guest or test machine that shares a network with things it should never touch, like a NAS or a router admin page. It is also handy when a piece of software keeps calling home and you want to see whether it still works without that.
Order matters here as well. ufw checks rules top down and stops at the first match, so if you have an earlier allow out that covers the same traffic, your deny never applies. Use ufw insert 1 to put the deny on top if needed.
Keep in mind that this filters by address. Blocking a cloud service this way rarely holds, because its addresses change. For that, block at DNS or use the service’s own settings.
Further reading: ufw(8) manual page