While the LM pilot flew the rendezvous and approach, the command module pilot took over once the craft were a few meters apart and flew the actual docking maneuver while the LM held a fixed attitude. The CMP had a better view of the situation (looking forward instead of upward) and had to do the extraction docking of the LM earlier in the mission (when no crew were aboard the LM) anyway, so was the crew member best suited to fly the docking.
At about 127:52 in the Apollo 11 transcript, Armstrong has stopped closing the range and is getting the LM attitude set up for the docking prior to hand-off:
127:52:05 Armstrong: Roger. We're station-keeping. ...
127:53:08 Armstrong (onboard): Okay. I'm getting about into the right attitude, I think. [Garble].
127:53:18 Aldrin (onboard): Yes.
127:53:21 Armstrong (onboard): That roll's pretty far. ...
127:54:11 Armstrong: Okay, Mike, I'll get - try to get in position here, and then you got it.
127:54:18 Collins (onboard): Okay.
127:54:39 Armstrong: How does the roll attitude look?
127:54:41 Collins (onboard): [Garble].
127:54:47 Armstrong (onboard): Let's see how the DSKY thinks it looks.
127:54:52 Collins (onboard): Have you stopped rolling yet?
127:54:54 Armstrong: I'll stop. Matter of fact, I can stop right here, if you like that.
A couple minutes later, Armstrong rather informally hands off to Collins:
127:57:34 Armstrong: I'm not going to do a thing, Mike. I'm just letting her hold in Attitude Hold.
It's unclear what the range is at this point, but a minute later Armstrong reports that the craft are 15 feet (5 m) apart. It's also unclear at what point the docking is actually completed; I think they're done at 128:03:
128:03:12 Armstrong: Okay. We're all yours, Columbia.
128:03:17 Collins: Okay. [Pause.] Okay, I have thrusters B3 and C4 safetied.
I went looking through some of the other flight journals to figure out what the handoff range was. The Apollo 15 transcript says "we're station-keeping at about 120 feet" (37 m), but that was for an opportunity to take photos of the CSM's scientific instrument module (SIM) bay.
If the CMP was disabled or the CSM unable to precisely maneuver, the LM could do the docking if the CSM could at least hold its attitude steady.
The mission commander had their hands on the flight controls during manual LM maneuvers. The LMP's role was more than just titular, however; they were generally responsible for operating the LM guidance computer, which actually did most of the flying apart from the terminal phase of landing and final portion of rendezvous.