WP-CLI offers a command to enable, disable maintenance mode and check if maintenance mode is enabled or not.
$ wp maintenance-mode status
Maintenance mode is not active.
$ wp maintenance-mode activate
Enabling Maintenance mode...
Success: Activated Maintenance mode.
$ wp maintenance-mode deactivate
Disabling Maintenance mode...
Success: Deactivated Maintenance mode.