Stop the guest VM.
Change the attached disk size in VM settings:

Attach a gparted iso or alternatively you can attach the original Ubuntu desktop ISO that you originally installed from.
Change the Boot Option for your VM to boot into the guest VM’s BIOS (‘Force BIOS setup’) to change the boot order with the cdrom first (by default it won’t boot from the attached cdrom as it’s set to only boot from cdrom if the attached disk does not boot first):

With the gparted iso or Ubuntu desktop install iso attached, restart the VM, and then run gparted.
Use gparted to expand the partition into the free space.
Once resized, reboot the Unbuntu guest (reset the boot order or unattach the cdrom iso image).
Use pvdisplay to get the Volume Group name
$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name ubuntu-vg
PV Size 39.76 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 10178
Free PE 0
Allocated PE 10178
Use vgextend with the volume group name and physical disk name to extend:
sudo vgextend ubuntu-vg /dev/sda5
Use lvextend with param “-l+100%FREE” to expand the logical volume:
sudo lvextend -l+100%FREE /dev/ubuntu-vg/root
Now use resize2fs:
sudo resize2fs /dev/mapper/ubuntu--vg-root
Done!
More info on using gparted here. Info on resizing LVM disks in this article here.