Is it possible for a pilot flying under VFR to switch to IFR during a flight?
Yes, a pilot can obtain an IFR clearance while airborne. There are at least three common scenarios:
Departing an uncontrolled airport. If a pilot has filed an IFR flight plan originating from an uncontrolled airport without ATC services, and weather conditions permit takeoff under VMC, the pilot can take off, and then contact ATC once airborne to receive the IFR clearance. The pilot must remain in VMC until receiving the clearance.
Filing while airborne. There are several ways to submit an IFR flight plan into the system while airborne: via data link or via radio by contacting a Flight Service Station (FSS). This works just like filing over the phone. Once processed, the pilot can contact ATC and receive the clearance. It can take a few minutes for the flight plan to become available; the controller may say something like "on request;" the pilot must remain in VMC until receiving the clearance.
Pop-up clearance. It is possible for ATC to grant an IFR clearance without filing a flight plan. This is possible (1) when the ATC facility controls the airspace for the entire flight: for example, if you intend to land at the airport served by the facility, such as getting an IFR clearance to fly an approach into the destination airport. (2) in emergencies. (3) workload permitting, ATC can coordinate with neighboring facilities to arrange a clearance, and even put in a normal flight plan. But they don't like to do this and may refuse.
In all three cases, the pilot must remain in VMC and abide by VFR rules until the clearance is received (which may take some time). Once the clearance is received, the flight proceeds under IFR just as if it had taken off IFR.