If you have completed a companion quest that grants a unique perk to that companion (eg. Clean Sweep for SAM, Tuned In for Vicar Max) and use the respec machine, those perks are removed and there's no way to get the quest perk back.
You get an additional perk point to allocate for that companion, but there's no way to use it for the quest perk.