You can definitely connect VPN on any virtual machine and this works on all major operating systems with a similar process as it is done on any real machine.
There are multiple reasons why connecting to a VPN on a virtual machine is reasonable. Here they are:
You would want specific applications to use VPN for maximum security and anonymity, while other applications utilize your normal connection
You would want to connect VPN on a VPS (Virtual Private Server)
Uses of VPN on Virtual Machines
You only need to install your desired operating system if you are creating a virtual machine on your computer. Then you just need to ensure that your virtual machine is successfully connected to the internet. Choose your VPN software to connect VPN or configure it manually.
Once you have configured your virtual machine, all of the applications that are installed on your real machine will utilize your actual internet connection, while the applications of virtual machine will utilize the VPN connection. It means that you can control which applications should use your VPN connection by running those on your virtual machine.
The settings of host machine can cause connection issues in VPN for the client machines on Virtual Private Servers. It occurs if certain settings regarding NAT, port forwarding, TAP, and others are incorrectly configured. Contact your network administrator or VPS host for further information about it.