It can be done by a good machinist who knows what he is doing.
I had a Colt upper that Colt themselves removed the carry handle and installed a rail in it's place.This was before mass production of flat top upper recievers.
The work was very nicely done.The fit,finish, and alignment of the screw holes was dead straight.The screws barely protruded into the reciever interior.
The only drawback was the rail was not Picatinney spec.I sold it off and bough a RRA A4 flat top reciever.
But it is less hassle and probably cheaper to buy a new stripped flat top upper and sell of the carry handle one.
SKBY.