A federal judge in Brooklyn sentenced Martin Shkreli to seven years in prison on Friday, following the former pharmaceutical executive’s conviction last summer on securities-fraud charges.

Federal prosecutors had sought a prison term of at least 15 years for Mr. Shkreli, who gained widespread notoriety in recent years for jacking up the price on lifesaving drugs and for his taunts and provocations over social media.

His...