It is not illegal to fit an aftermarket exhaust, but the noise level needs to comply with the noise label that is attached to the bike. The label looks like this: