I can confirm Vakil's information. We followed his suggestions and it all eventually worked out.
A Moroccan friend went along us (the seller is also an expat like me). When we picked up the transfer form at a librairie, my friend suggested that we ask the clerk to complete the form for us, which he did. That simplified things and reduced the possibility of errors. But there were multiple steps:
(1) Seller and buyer (and Moroccan friend) go to librairie to get transfer form. In our case, this librairie is also a "multi-services" place which can accept payments for electric bills, administrative fees, car taxes, etc. You should use a place like this if possible.
(2) Clerk at librairie completed form, using information from the existing carte grise (car ownership/title card) and from the seller's and buyer's national identity cards or, in our case, cartes de séjour.
(3) Clerk at librairie also made recto-verso photocopies of carte grise and our cartes de séjour.
(4) We went to a nearby "legalization office" (can't remember Arabic name) where we signed the transfer form in the presence of an agent and had the photo copies of the existing carte grise and our cartes de séjour "legalized" (notarized). The stamp fees came to 8 dirhams.
(5) We went back to the librairie, where the clerk entered all the information from our form into the car registration database (I think), essentially running a check on the status of the car.
(6) Since this librairie was also a "multi-services" place, we went to another clerk in the store who was stationed behind a special window like a bank teller. He took our notarized form and legalized photocopies, along with the original carte grise and cartes de séjour, and entered it all into another computer database. This generated a document acknowledging the registration of the sale and listing a fee of 705 dirhams as amount due. I paid that plus a 25 dh surcharge or processing fee, for a total of 730 dirhams.
(7) Next we went to the vehicle matriculation office in the center of the city. There were quite a few people there. A fellow at the gate, who did not seem to be an official employee, reviewed our form for accuracy and told us we needed an appointment. My Moroccan friend phoned the librairie to ask if he had set up an appointment for us. The clerk replied that the system had been blocked and that he had not been able to get us an appointment! He evidently forgot to tell us about that.
(8) My Moroccan friend, who is a master of tact and negotiation, appealed to several people at the office on my behalf, and they squeezed me in. This was kind, as the seller is about to leave the country. It may have upset some others waiting in line, but no one protested aloud.
(9) The agent at the matriculation office received all my forms, including the old carte grise, and gave me the portion of the transfer form that amounts to a temporary carte grise issued to the buyer. It's good for 60 days. I'll go back later to pick up the permanent card.
All's well that ends, well, but the process did take a total of nearly four hours, including waiting to get forms legalized and waiting at the matriculation service.
SUGGESTIONS:
(1) Most importantly, ask a trusted Moroccan friend to accompany you, preferably someone who has been through this procedure several times, the more recently the better. Buy him lunch or at least take him for coffee when it's all over! And be sure to continue being his friend afterward.
(2) Be sure that you have an appointment at the matriculation service before you go there. It's good that they require appointments, especially as the pandemic continues. I'm embarrassed that I had to be given special consideration, but I appreciate their flexibility in this case. Most importantly, it made it possible for the seller to complete the transaction so that he could continue with his preparations to leave the country.
Thanks again, Vakil!