How to add an icon and bind a command to the right side of the top menu bar

I want to add an icon and bind a command to my top menu bar