Talk to Maxson shortly after completing Liberty Reprimed. He'll send you to find Danse who's gone AWOL. After talking to Maxson, head to Quinlan and talk about the order. Haylen will be here and will invite you to follow her where she'll talk to you in private. She'll tell you that you'll find Danse in Listening Post Bravo.
Once there, take out the turrets outside then operate the terminal to Power the elevator. Take the elevator down. Destroy the protectrons and talk to Danse. You'll have the option to have him execute himself, do it yourself or refuse to execute him. If you refuse to execute him, you'll have to convince him that he's a not a threat to mankind.
Leave the place and once outside, Maxson will be waiting outside and confront you for not executing Danse. You'll reach the point where Maxson will order you to execute Danse, have him do it, or talk your way out of it. If you successfully convinced Maxson to spare Danse, he will consider him dead and will not be allowed to set foot in the Prydwen (as well as the Cambridge Police Station and airport) or make contact with any Brotherhood personnel.
After Maxson leaves, you can still convince him to stay as your companion. However, you can't bring him to any of the locations mentioned. Return to the Prydwen and talk to Maxson. You'll be promoted to a Paladin and you'll be given Danse's own quarters and his personal Power armor.