IMO it would be unethical for a lawyer to refuse to represent a guilty client and only represent ones they thought were innocent. The whole point of having a lawyer is to help you navigate through the system so you don't get screwed and get a just result. Guilty people deserve that as much as innocent people.
Now if the prosecution is so screwed up that they can't prove a guilty person is guilty, that really isn't the guilty person's lawyer's fault. That's on the prosecution for not doing their job.