Elon Musk took the stand for more than 3 hours and sparred with a lawyer at his Tesla trial as the judge says one of his remarks was ‘inappropriate’