Enter your on your Mac, choose Messages > Preferences, click iMessage, then select Settings.
Do one of the following:
Make iMessage inactive: Deselect “Enable this account”. When you make iMessage inactive, your status is displayed as Offline.
Note: If you just want to stop receiving text messages sent to your phone number, deselect the phone number under “You can be reached for messages on”. See the Apple Support article Apple Support article: Use Messages with your Mac