One case of this that's getting a bit old but was highly influential in artificial intelligence was Phil Agre and David Chapman (PhDs at the MIT AI Lab in the late 1980s). They did everything together, but wrote completely different dissertations. They agreed in advance how they would divvy up the output.
Since a PhD has to have a novel contribution, I think this is the only way it can work. You specify your contributions in the introduction and conclusion, and these can only be contributions by one person, for one dissertation.
Personally, I had a little bit of overlapping text in two of my dissertations (which for bizarre reasons came out nearly the same time), but it was only the literature review, which at the time I didn't think of as a contribution, and I clearly stated the overlap in the later dissertation. Also, I didn't claim that the thing I was best known for at that time (an action selection mechanism) was a contribution to either dissertation, just to be certain there could be no claim I'd made overlapping contributions (One was in Psychology & one was in Systems AI, so they really were pretty different.)
Basically, by the time you are ready for a PhD, you should be able to make any number of contributions. So being productive and publishing articles is the main thing to worry about, and then secondarily following through, and following the rules, so you get your degree. Your dissertation is not a documentation of your life's work – it's just one coherent document making a very clear academic contribution. Hopefully two good students working together would make more than enough contributions that they can divide them up and each write interesting dissertations.