If you have the ability to install rmate on the remote server, then you can use Remote VSCode.
For this, extension's documentation describes, you configure the VS Code user settings for the extension, start the extension's server from the command palette with Remote: Start server, open an ssh connection to the remote server with a remote port forwarded with ssh -R 52698:localhost:52698 [email protected], and then you run rmate -p 52698 <file> on the remote server.
This will cause the specified file to open up in your local VS Code editor, and any changes made to it there will be reflected in the copy on the remote server very soon after you save them.
Alternatively, you can use sshfs to mount the remote directory as if it were a local directory. This is my preferred method nowadays for editing remote files using a local editor. On systems using apt you can install it with apt install sshfs. On systems using yum you can install it with yum install fuse-sshfs.
Once installed, make a local directory in which you'll mount the remote directory. We'll call it /mnt/remote for this example. Go ahead and mount it with sshfs:
sshfs -o allow_other,default_permissions [email protected]:<src dir> /mnt/remote
Where <src dir> is the absolute path to the remote directory you would like local access to.
Add the IdentityFile=/home/$USER/.ssh/id_rsa option after default_permissions if you are using key authorization, as you ought to be.
You may need to tweak the permissions of /mnt/remote, and use sudo for all of the commands listed above.
Many other options are detailed in the man pages. Consider also using large_read for greater efficiency, and reconnect,ServerAliveInterval=5,ServerAliveCountMax=15 for greater reliability.
Once the sshfs command succeeds, you should find that the remote directory is accessible as the local directory /mnt/remote. To edit the contents of the remote locally, simply open up VS Code to that directory with code /mnt/remote, and edit away as if it were all local! Your changes will be reflected in the remote files very soon after you save them.