You can inject system messages at any point in the page render cycle like so:
JFactory::getApplication()->enqueueMessage('My glorious message','error');
The jdoc tag basically creates the place host and loads needed files required to inject and display messages. Hope this helps, but depending on exactly where you plan on creating message in code could be relevant. If you are having issues still post the code where you are creating the message.
* Edit 1 *
We can leverage your custom template and Joomla's Output Override's feature to accomplish what you would like. For this example, I'm assuming we will overriding the article component view.
First thing is to create the directory path in your custom template's root folder:
templates/mytemplate/html/com_content/article/
Next would be to copy the core content component default.php file to the new directory, you would find the file for this example at this path:
components/com_content/views/article/tmpl/default.php
Now, at the top of this file, you would add the method to queue up a new system message:
JFactory::getApplication()->enqueueMessage('My glorious message','error');
I pasted three links to Joomla Docs regarding overrides to provide more detailed explanations.