If you want to lock local session, then you can run the following command to list all sessions and then find out the session ID for that specific session.
$ loginctl list-sessions SESSION UID USER SEAT TTY 7 1000 user1 seat0 tty2 c3 1001 user2
Now, use the following command to lock that specific session (your local session). In my case, SESSIONID c3 with user2 is created from RDP. I can close local session i.e. 7 (on tty2).
loginctl lock-session SESSIONID
EDIT1: Automate the above task
Once your'e in your remote session, it will lock your primary display after 10 seconds.