The problem with dangling participles comes when we read the participial phrase and connect it to the subject, but for whatever reason the true subject of the sentence has been omitted and we end up connecting it to the object instead.
In the case of your specific sample sentence, it looks like dangling participles are writing carefully, which is obviously nonsense as they're an abstract concept and are incapable of performing actions. This can be fixed by specifying the subject, either converting it to active form or keeping it passive:
Writing carefully, dangling participles should be avoided by you.
Writing carefully, you should avoid dangling participles.
There's another issue with this sample sentence that isn't related to your question, but I'll point it out anyway. The participial phrase "Writing carefully" implies ongoing action and isn't a good fit for the clause with which you've followed it. I would use it, for example, when saying something like
Writing carefully, I penned my memoirs.
For a clause like the one you've used, I would use something like "When writing carefully," instead:
When writing carefully, you should avoid dangling participles.