it's not illegal. but in terms of medical folks and paramedics/emts in particular, self harm is still very much a grey area. if you turn up at a medical hospital or have emergency services come to you after having self harmed, they are unfortunately very likely to assume you tried to commit suicide, and treat you as such until you've had a psychiatrist evaluate you. they don't generally tend to understand the difference between self harm and suicide.
good providers can usually take the time to understand the difference, but in emergency situations most medical folks won't be qualified to do that. which sucks, but does make sense. it's better to see trained mental health professionals if you can.
so no it's not illegal. but it's also not exactly something worth condoning either.