How to configure bash/zsh to show a small key icon when the prompt asks for a password like Mac terminal?
Is this even possible?
Your shell cannot help you because it isn't even active at this point. It's just sitting in the background waiting for the command to terminate. The shell runs the sudo command, after that sudo interacts with the terminal. (Suggested background reading: What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?)
It may be possible for your terminal to do what Mac terminal does. Certainly Mac terminal has this feature. I'm not aware of other terminals emulators with this feature, you may want to make a feature request to the developer of your favorite terminal emulator.
What you will notice in this case is that typing characters is being accepted by the
read prompt, just the shell is not echoing them back to you and so it appears that it is not accepting input.