I have a account page in Salesforce where I want to display a text message on the top of the page. I tried to achieve the functionality but it always displays the message near the buttons. Below is the screenshot.
I suppose you are talking about standard page layout ? If so, it possible to display error message near related field or near buttons. if you want to display messages in other places, you need to override standard layouts with custom VF page.
For the reference check example