You have to find the account icon you want to use. They're typically fake accounts created just to supply the icon, which usually end with "plz". For example, that derpy is mlpderpyplz.

Then you just put :iconmlpderpyplz : (without the space) in your message to make it appear!