How to render text on top of the objects that are generated on the map using a script?

The text is only displayed in the canvas and the objects over which to render text are out of the canvas. How to render text on top of the objects that are generated on the map using a script?

My suggestion, if understanding the question, is to try taking a look at Unity - Scripting API: Camera.WorldToScreenPoint to grab the position of the monsters and then put the text over them from there.