Their job, distasteful as it may have been, was to defend the client they had been assigned, even though they knew he was guilty. Failing to do that would have been a grave breach of professional conduct. These guys weren't Johnny Cochrane, who could accept or turn down a job on the basis of how much the client could pay or how much publicity he could get out of the trial; they were public employees doing a difficult job.
This is not an easy call, and I don't see how you could pass a law that wouldn't create more problems than it would solve. Would you trust a lawyer who could rat you out without consequences to himself? Do you think the guilty aren't entitled to competent legal defense?