The justices decided unanimously in favor of a man who argued that a law barring guns from anyone who regularly uses illegal drugs violates the Second Amendment.