A Massachusetts man has pleaded guilty in federal court to trafficking cocaine and illegal guns in and around the Boston area, the U.S. Attorney said Thursday.