I believe that in Pluto scripts are isolated, so you can’t access variables created inside scripts from other scripts or other parts of the DOM by default.
The JS internals of Pluto are not very much documented so it’s not easy to understand what happens especially if you are not proficient in JS and Preact.
Now, if you really want to make your function available in the rest of the browser and working with your code, you have to attach it to the window (at least that’s a way that I know of).
You can easily do that by adding window.toggleColumn = toggleColumn before your closing </script> tag and your code works.
That being said, use of onclick is usually discouraged and the addEventListener is the recommended method.
This is especially true in Pluto where you need to pollute the window object to make functions.
In general I think the html code example you picked for the truth table is not the best in terms of design and readibility of the code.
If you want to see more examples on how to use JS inside pluto to make nice widgets you can look at the various notebooks in the PlutoUI package