Simple solution could be, to store the debug on/off status into a variable each time you change it.
When changing it in userfunctions, you could use a well known workaround for the fact, that BASIC! doesn't have "classic" global variables, see below.
The little trick here is, that if you create a list at a defined point of a program, you always know it's reference(=list-pointer) and so you can refer to it from inside a function w/o hand-over this reference every time (here the mentioned list is created at the very beginning and therefore has the reference "1")
LIST.CREATE n, globals
LIST.ADD 1, dummyGlob1, dummyGlob2, statDebug, dummyGlob4
DEBUG.ON : LIST.REPLACE 1, 3, 1
DEBUG.OFF : LIST.REPLACE 1, 3, 0
LIST.GET 1,3, statDebug
IF RND()>0.5 THEN debugOn() ELSE debugOff()
PRINT INT$(ctr); " statDebug= "; INT$(isDebugOn())