I mean, having firmware that securely wipes your phone in case it's used by an unauthorized party is a reasonable and desirable feature. It's not generally illegal to set that up.
Same with destroying documents. Having a retention period and destroying documents which have PII and could be used for identity fraud is a good practice. It's not generally illegal to do that either.
Where you get into trouble with the courts is when you have a specific obligation to retain or transfer information and you destroy it instead.
Intent makes all the difference in the eyes of law.
If a jury of your peers decides that you configured that firmware to protect your data from thieves, then it is not a problem.
But if a jury of your peers doesn't buy your assertion of that, and instead becomes convinced that you applied that (otherwise reasonable and legitimate) feature with the intent to destroy evidence of a crime so that it doesn't reach the court, then setting it up was a felony.
It is illegal to intentionally destroy something that you suspect could be evidence in a future criminal case against you. Say you operate an illegal drug network from a specific phone that you've intentionally setup to self-destruct at reboot. Both you and the cops know there is likely evidence on there that would implicate you. Then, if you either intentionally reboot the phone or maybe the battery dies while in police custody before they can access it and the phone is wiped, you could be liable for destruction of evidence. However, if it's just a standard smartphone and you accidentally drop it in the toilet, unintentionally destroying all evidence, you may not be liable.
Basically, if you intentionally destroy evidence, either actively passively, you're liable.
It is kind of a broad law and is difficult to prosecute in many cases. The cops have to know that you did the crime and prove that the evidence existed. If you murdered someone and made it look like a suicide, the cops would have to not only suspect you but also know that you left fingerprints and DNA behind that are no longer present.
Same with destroying documents. Having a retention period and destroying documents which have PII and could be used for identity fraud is a good practice. It's not generally illegal to do that either.
Where you get into trouble with the courts is when you have a specific obligation to retain or transfer information and you destroy it instead.