If possible, you should do whatever the operating handbook for your aircraft says but don't hesitate to do something different if you think it's necessary (more on that below).
I checked a couple of POHs that I have to hand and they don't mention the doors specifically, but there is a slight difference in what they say about cabin ventilation.
The C172S checklist emphasizes avoiding drafts, including shutting air vents and ventilating only after fighting the fire:
ELECTRICAL FIRE IN FLIGHT
- Master Switch -- OFF.
- Vents, Cabin Air, Heat -- CLOSED.
- Fire Extinguisher -- ACTIVATE.
- Avionics Master Switch -- OFF.
- All Other Switches (except ignition switch) -- OFF.
AFTER DISCHARGING FIRE EXTINGUISHER AND ASCERTAINING THAT FIRE
HAS BEEN EXTINGUISHED, VENTILATE THE CABIN.
- Vents/Cabin Air/Heat -- OPEN when it is ascertained that fire is completely extinguished.
The PA28 checklist on the other hand says that the vents should be open:
FIRE IN FLIGHT
Electrical fire (smoke in cabin):
Land as soon as practicable
But practically speaking, fire in the cabin is a really extreme situation and it's hard to say that you should always follow the checklist (if you even physically can). For example, if the cabin fills with smoke and you can't see anything at all you might have to try to clear the smoke somehow just to keep control of the aircraft, even at the risk of feeding the fire. The Piper POH acknowledges that the pilot is the best person to decide what to do:
The procedure given is general and pilot judgement should be the
determining factor for action in such an emergency
For a real-life account of a cabin fire in a C172RG, see this AOPA Real Pilot Story. They had to open the door to be able to see and land, which reinforces the point about doing whatever you have to do in an extreme scenario.