Here’s one for you.
Student pilot - left seat
Pilot examiner - right seat
FAA inspector - back seat observing the Pilot examiner conduct a check-ride.
Here’s a second scenario:
Student pilot - left seat
Flight Instructor - right seat
Chief Flight Instructor(me)- back seat observing the Instructor.
You can bet your beans that I am PIC in the back seat in that scenario.
In case of accident or incident the FAA would consider the highest rated pilot in a position to interfere in the outcome of the flight as (partially) responsible.
* It is however not loggable time.