How can I create a custom page for this error?

Check out the source of dead_db() which powers the message.

You’ll see that you can create a file db-error.php in your WP content directory (which by default is /wp-content/) and it’ll load that instead!