One way is to add delegate control to master page. Follow the article: http://www.sharepointpals.com/post/Step-by-step-procedures-to-create-a-delegate-control-in-SharePoint-2010
However for some reason, it’s required to set ControlSrc to “~/_ControlTemplates/15/…” or else the control won’t be used.