How can i remotely type my passcode while iphone is plugged to my mac
Definitely not possible
no access over computer keyboard if your device has not been jailbrokenwith openssh preinstalled before

You can use iCloud Backup on recognized WIFI networks to sync automatically
if previously enabled, though


  If your iPhone gets recognized by iTunes on your Mac, you are still good to go for a screen replacement considering it not being as expensive as a data loss, nor the lightning keyboard and more important you don't lose your app tokens, for example some banking apps, app-related logins, authenticator apps, etc.