This week’s mass shooting at a Maryland newspaper office by a man who for years menaced reporters on social media spotlights the struggle law enforcement and social media companies face as they try to police cyberstalking and harassment on platforms that are used by billions around the globe.