Manual:$wgReadOnly

Details
If set to a string (e.g., in LocalSettings.php), $wgReadOnly disallows editing, displaying the string given as the reason. Functionally the same as $wgReadOnlyFile, but using a variable instead of a file.

Note that some of your installed extensions may write data nonetheless.

The above example locks the database and provides a default statement on edit pages and also gives the included string 'site maintenance' as an explanation for why the database was locked.