Short answer you can't because true 24 bit colours (rgb) are not part of an accepted standard and it will be a hit or miss whether a terminal supports it or not. You should instead use a predefined colour from the terminal's pallette. ANSI 3/4 bit colours
That being said, some terminals do support true 24bit colours, and most of them use this format: \033[48;2;r;g;bm
the 4
in 48
sets the colour as the background, it can be changed to 3
which defines the colour as foreground. (more info)
The r g and b letters represent an 8 bit number in decimal so printf "\033[38;2;159;188;0mhello
would print a hello in the colour you wanted (#9fbc00
) but it wouldn't reset once the command was executed so you need to tell the terminal to go back to the original colour. To do that, you need to use another escape sequence.
\033[0m
Now knowing that, a bug free way to print Hello world!
in #9fbc00
would be
printf "\033[38;2;159;188;0mHello world!\033[0m\n"
.
ps: echo doesn't like escape codes, use printf if you want to format stuff