is it possible to develop a cuda program in a virtual machine that has a ubuntu installed

Yes, it's possible.

The presenter in the video is using an Amazon EC2 cloud GPU instance.

In general, many types of VM (virtual machine) offerings can host a linux OS, upon which the CUDA toolkit could be loaded and codes compiled that way.

There is a difference between compiling a code and running a CUDA code, however. Running a CUDA code usually requires a CUDA GPU be present/available. This can be done using some types of VMs/hypervisors, but not every VM hypervisor supports the ability to place a physical GPU device into a VM (which is required, currently, to be able to run a CUDA code in a VM).

In general, to provide a GPU within a VM suitable for CUDA usage (currently) it is necessary for the VM/hypervisor to support some sort of PCI Passthrough capability.

Providing a full step-by-step tutorial would depend on the choice of specific hypervisor and is beyond the scope of an answer I can provide here.