I am happy to report that I got it working. In this macro, rather than turn a palette off or on, I turned a different window off or on, that is, the Display Progress Bar window. But it should be very easy (trivial) to replace that with a palette action. What I did in this macro was get the framework working, and anyone can replace the Display Progress Bar with anything that they want, including palettes.
You may want to replace the F18 hotkey with some other hotkey. Note that there are two places in this macro where you have to change that hotkey.
This macro can be simplified. I had expected it to require 4 states, but a couple of the states (2 and 4) were hardcoded instead of softcoded. I left it as is so that you can see my thought process of using many "states."
I hardcoded a value of 0.5 seconds in this macro, because that's what you seemed to want. You can also change that if you wish.
It seems to work for me, but if you find a problem, let me know. I often write code like this, involving states and timers, so this took me under 30 minutes.
F18 Tap Test Macro (v11.0.4)
F18 Tap Test.kmmacros (12 KB)
As it turns out, the concurrent macros are completed so quickly that you should never see more than two copies running concurrently. I had expected 15, but I forgot how quickly these macros would complete.
I just realized I omitted something. This solves the hard part of your request, but the easy part of your request was to allow the function key to maintain its regular effect if it is pressed once. I think that will be an easy fix, but I need a little more time to consider it. It all depends on whether you want the regular hotkey function to be suppressed when the user holds the same key down for a long press. If not, the solution is trivial: just create a regular hotkey macro. But if you want the suppression to exist, then we have to add a little code. So which is it?