This sparked interest in me and I looked around for a solution but it's beyond my understanding. It looks like it can be done via dll call/sendmessage but the syntax is the challenge. I found this:
https://stackoverflow.com/questions/70260518/how-can-i-refresh-the-taskbar-programatically-in-windows-10-and-higher
It seems right on the cusp of what you're trying to do but, again, beyond my meager understanding.
Also killing StartMenuExperienceHost.exe won't refresh the taskbar.