You will need to run the LSP server on the machine where the source code is, because the LSP protocol is predicated on the server having access to all of the source code at once, as files on disk.
I don’t see much documentation about it, but I am given to understand that if you open your source code via TRAMP then Eglot will simply search the remote host for the LSP server program, rather than your own computer. If it finds it, it will simply run it there on the remote host as expected.
Alternatively, most LSP servers can be set up to run as a service that listens on a TCP port. You could configure your LSP server as a service on the remote host, and then configure Eglot to connect to that port instead of trying to run a program. You would probably also need to configure SSH to enable local forwarding to that port over your ssh connection. The LSP protocol is not itself encrypted or authenticated, so you wouldn’t want to allow just anyone to connect to it; don’t allow that port through your firewall.