There is nothing illegal about taking a second job except if you work in certain government positions or work in certain licensed occupations. All the tax law cares about is that you report all the income that you earned and pay the tax on it. Each state has its own tax laws, and they do vary from state to state.
There isn’t any law that says your second job has to be as an employee; you can be self-employed (i.e. get a 1099). Again, for the most part the law doesn't impose any restrictions on the work you can do.

