I have basically installed a package xserver-xorg-video-dummy with sudo apt install xserver-xorg-video-dummy then created a config file named xorg.conf with following content:
Section "Device"
Identifier "Configured Video Device"
Driver "dummy"
EndSection
Section "Monitor"
Identifier "Configured Monitor"
HorizSync 31.5-48.5
VertRefresh 50-70
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1366x768"
EndSubSection
EndSection
I also created two scripts monitor.sh and nomonitor.sh:
monitor.sh:
sudo rm /usr/share/X11/xorg.conf.d/xorg.conf
nomonitor.sh:
sudo cp xorg.conf /usr/share/X11/xorg.conf.d/
You can execute one of the scripts over the ssh or when the monitor is attached.
You will need to execute sudo reboot after executing the scripts.
You can execute then xvnc or teamviewer as you like.