this can be achieved by creating gnome-shell-extension.
Tested in gnome-shell --version 3.38.1
Run below commands one by one to create required files.
mkdir -p $HOME/.local/share/gnome-shell/extensions/KBD
touch $HOME/.local/share/gnome-shell/extensions/KBD/extension.js
touch $HOME/.local/share/gnome-shell/extensions/KBD/metadata.json
extension.js file contents, copy paste in above created extension.js file.
Notice the 11th line, Util.spawnCommandLine("bash /home/admin/mykbd.sh") replace /home/admin/mykbd.sh with path of your script that toggles what you are looking for.
'use strict';
const St = imports.gi.St;
const Main = imports.ui.main;
const Util = imports.misc.util;
let button;
function _myKBD () {
Util.spawnCommandLine("bash /home/admin/mykbd.sh")
}
function init() {
button = new St.Bin({ style_class: 'panel-button',
reactive: true,
can_focus: true,
track_hover: true });
let icon = new St.Icon ({ icon_name: 'input-keyboard-symbolic',
style_class: 'system-status-icon' });
button.set_child(icon);
button.connect('button-press-event', _myKBD);
}
function enable() {
Main.panel._rightBox.insert_child_at_index(button, 0);
}
function disable() {
Main.panel._rightBox.remove_child(button);
}
metadata.json file contents, copy paste in above created metadata.json file.
{
"name": "KBD",
"description": "KBD",
"uuid": "KBD",
"shell-version": [
"3.36"
]
}
once you are done with copy pasting in the two files. Refresh the gnome-shell with Alt+F2 r Enter method or logout and login.
Then to enable the extension, run below command.
gnome-extensions enable KBD
Again Refresh the gnome-shell with Alt+F2 r Enter method or logout and login.
Now you will see the keyboard button at the top right corner. when you click it, it runs the script you prepared.

Please note that, extensions are disabled when screen is locked and enabled once unlocked. So you wont be able to click this button on lock screen.