First off, you will need to place some code on your site. You can use $context[‘user’][‘is_admin’] to hide and show it. You will need to use CSS to build some sort of button/clicker identifier. I won’t go over that here as I assume your already customizing your SMF install.
Now with this installed, you can do something like this in your Settings.php
$db_show_debug = !empty($_COOKIE['smf_debugger']) ? true : false;
This has no security as all it will take is somebody to guess your cookie name to enable debugging. You should ensure the cookie name is unlikely to be guessed.