changing icon in apple script

I found same questions, but not answers. Can anybody point me in the right direction?
I created my own mute mic button on the touchbar. When muted I want to show another icon or another color than when not muted. I understand I have to change the apple script. How? This is the script that I use

on getMicrophoneVolume()
input volume of (get volume settings)
end getMicrophoneVolume
on disableMicrophone()
set volume input volume 0
end disableMicrophone
on enableMicrophone()
set volume input volume 100
end enableMicrophone

if getMicrophoneVolume() is greater than 0 then
end if

Can you change it through alternative icon regex? Or, along the lines of how custom album art widgets retrieve the album art and set it dynamically? I don't know how to create them, but I remember seeing those two distinct methods for setting icons.

Thanks for your help, but I don't have the skills to add that to my script. I copied it from another place and have no idea where and how I should put the code

In the end I used an applescript/javascript widget with this code:

if input volume of (get volume settings) is 0 then
return "micOff"
return "micOn"
end if

In 'common' I can then select the icon and alternative icon + color