Nope, all it does is to slow down the execution. Generating a swap file here is pretty fast anyway tho. That's what you get with modern and fancy NVMe SSD's. If you want a secure swap you should encrypt it. Something like this might work:
dd if=/dev/urandom of=swapfile.crypt bs=1M count=64
loop=$(losetup -f)
losetup ${loop} swapfile.crypt
cryptsetup open --type plain --key-file /dev/urandom ${loop} swapfile
mkswap /dev/mapper/swapfile
swapon /dev/mapper/swapfile
Tho, this might not make any sense if the disk is already encrypted. It's also not that relevant on a cloud instance without encrypted disks. I suppose if you keep your data on a encrypted block storage device then you'd want to encrypt the swap too. Let me know if it works. 🙂