I don't see how it would be "illegal".

If I were doing work on the side it would not be as an employee of "Joe's Electric", and I would be submitting my ticket # on the permit to do the work so there would be no problem discerning whose issue it is.

I realize that this is looking for a loophole but the idea of being limited to working for one company and then not being able to, for example, wire my in-law's cabin at the lake after hours because I can't get permission to do so from my boss seems ridiculous.