Representatives of Twitter Inc. and Elon Musk continued Thursday to work to hammer out an agreement that would allow the billionaire’s purchase of the social-media company to proceed, with the parties racing to seal a pact by Monday, a person familiar with the matter said.