Yes, it is illegal, but most of the time a police officer will just give you a warning and tell you to get it replaced or repaired within the next week or month.
It differs from state to state, so it might be illegal.