That's dependent on the terminal, not the operating system.
Some terminals can be configured to store arbitrary strings; I did this for wyse-50's a while back, using escape sequences to program them.
More recently, you can set the
translations resource in
xterm to send a string. There is no escape sequence for this (which you would find useful:
DECUDK is the closest, and sends its result in hexadecimal).
Some terminals (such as Terminal.app) have a preferences dialog which lets you put arbitrary strings there. Again, no escape sequence, but definitely configurable.
Some (apparently gnome-terminal and konsole) let you do some limited configuration of the keyboard.
Ultimately the answer reduces down to finding
- if the terminal you are using supports that feature, and
- if so, how to use it effectively.
This answer deals with passwords in terminals, rather than GUI. In a GUI, the application may not even see a function-key as text. GUIs have different constraints, e.g., (per comment) on Windows, passwords may be prompted in the security desktop, so it wouldn't matter much how the keyboard is setup. In particular, since that runs separated from other processes, you could not use an add-on (such as autohotkey) to store/paste passwords. Other GUIs have their own rules (see
XSendEvent for instance), which are not necessarily determined by the operating system, but the runtime libraries.