Yes. It's called command substitution. You can read about it in the man page of your favorite shell.
I believe most (if not all) shells can do it, but I only know the syntax for bash. Using your own example, the following will work:
kill -9 `pgrep firefox`
kill -9 $(pgrep firefox)
kill -9 "$(pgrep firefox)"
bash has the $( ) syntax which is much better than the back tics ` ` since it can be nested or placed within quotes.
You may also want to check out the command xargs. It would probably work best for your first example:
locate mp3 | xargs -d'\n' mplayer
EDIT: First example used to say killall instead of kill.