Love Plus supposedly has a thing to brick flashcarts, but I never have played it so I don't know. Besides, if your flashcart is upgradeable, then you can just reflash the firmware onto it.
hum--- is it legal to place malicious code? technically flash carts can be used to legally back up owned games- and reflashing is something 90% of r4 users won't be able to figure out-
Not illegal as far as I know. Especially if Nintendo wants to protect its games. And you can't reflash an R4 anyways as far as I know since most are not updateable.