How to get `hash -d` shortcut path of a full path in ZSH?

If you just want to print the string, you can do

% print -D /a/b/c/d
~x/d

See https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html#index-print

If you need access to the string in a script, use

${(D):-/a/b/c/d}

See https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion-Flags