You can do this via System Preferences -> Security & Privacy -> General, see How to set a lock message on the login window of your Mac for details.
Via Command Line
sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "The Custom Message here.
The message can be multi-line as well and will work fine"
As a policy banner
You can also set a policy banner by following this instructions from Apple
- Create a plain text (.txt) or rich text (.rtf) document that contains your banner.
- Choose File > Save, then enter PolicyBanner for the document name.
- Copy the PolicyBanner file to the /Library/Security/ folder.
chmod o+r /Library/Security/PolicyBanner.txt
This may be useful for people who wanted to show the custom message on lock screen due to reasons like when their Mac is lost then they can display a contact number. Because the custom message of login window seems to be displayed only when we login-in and then lock the screen. During initial login, the custom message is not displayed. (Probably because this custom message is user specific and not applicable to all the users).