NO it is NOT illegal.
There are a million "John Doe´s" and John Smiths out there.
If you use a different name than your own than you are just being smart by trying to hide your identity.
You cannot get into trouble so don t worry and don't listen to what other people say.