This is called Do Not Disturb mode, I guess stock Android don't have it, but just search for "do not disturb" on the PlayStore.
You can also go into the Messenger app, tap on the 'three little dots' on the bottom right to go into Settings, scroll down to the Notification section.
Or to disable notification sound system wide, Settings -> Sound and manually change the notification sound to "None".
You can also disable the status bar notifications for each individual apps by going into Settings -> Apps, tap on a given app and uncheck "Show notifications".