Martin Shkreli, the boisterous former hedge-fund manager and pharmaceutical-industry executive, was chastised Wednesday by a judge for speaking to the media during the early days of his securities-fraud trial.