Not quite the same but I found an applescript that converts the macOS file path to a URL scheme and copies it to your clipboard. I then added it to Automator as a service so that I can call it with a keyboard shortcut in Finder. Limitations: The link generated from this script will not work on any device except for the device that created it. But perhaps you can modify it to your needs. Here’s the script:
(* To use this script, select a file or folder in Finder, then run this script. This script will get the file path, convert it to a URL and save it to your CLIPBOARD.*)
(*LIMITATIONS: This script does not appear to work with files outside of FINDER.*)
return do shell script "python -c \"import urllib, sys; print (urllib.quote(sys.argv))\" " & quoted form of thepath
tell application "Finder"
set sel to the selection as text
set the clipboard to "file://localhost" & my path2url(POSIX path of sel)