In the age of at-your-fingertips social media, some defense attorneys are struggling with a new challenge: controlling their own clients.

Just ask Martin Shkreli's lawyer.

Practitioners said they had rarely encountered a client as unruly as Shkreli, the pharmaceutical executive now on trial for securities fraud. They had little to offer in the way of advice for lawyers in similar circumstances—other than to spell out the consequences, and if necessary, walk away.