I'm skeptical that a phone would be able to tell the difference between a driver and a passenger reliably, if at all.
Speaking as a software engineer, there are a few possible approaches for differentiating the two. Ignoring, of course, questions of whether we *should* mandate such functionality and whether it would be effective, here are my off-the-cuff thoughts:
1) The straight-forward approach would be to lock-out the device--whether it be altogether or just forcing a switch to an alternative interface on the device itself, similar to a CarPlay derivative or Android Auto (which became usable without a head unit a few months back)--whenever the device is charging via a car's USB port. When the device is plugged in, the car would signal back via the data pins that the device is connected to a car and should implement an alternative interface.
Unfortunately, this is kind of a nightmare with negotiating power draw.
Different manufacturers (such as
Apple) have implemented different control methods with resistive voltage dividers on data lines to do so and to avoid having to use enumeration chips that would drive up per-unit costs.
[0][1] So this 'straight-forward' approach is pretty much a no-go with existing charging ports, as it would require changes to the USB Battery Charging 1.2 spec, as well as physical changes to both the charging ports and your devices to identify "this is a car" compared to any other type of charging port. And that's ignoring the possibility of fast charging protocols as well. Maybe you can modify something in the
USB Audio Device Class 3.0 specs to accomplish that that were announced last fall, but we aren't going to see car manufacturers spring for using USB 3.0 anytime soon IMO. And you need to standardize that with the car, car audio, and phone industries.
But what about when it's connected to a head unit and communicating current song data? Similar problem there, as well. You can connect your phone to other USB devices to play music with, so you need to differentiate between "car" and "not car." Nothing in the existing USB specs or physical hardware is setup to do so.
Finally, even if you *did* setup a lock-out system through a particular port, many cars nowadays have more than one. If someone wants to get around it, they just use another one or even a third-party car charger plugged into the car's 12V socket. Worse yet, power inverters and standard 115V sockets so you can always use their regular wall charger to sidestep everything. Or, you know, just keep the phone unplugged.
2) Ok, that approach sucked. So what about using fixed, very low-power bluetooth or NFC beacons in the car, similar to iBeacons already in use in many retail settings? It seems simple enough, but there are some serious problems. First, your device would need to know the car's make and model, and the exact locations of the beacons inside it relative to the rest of the space. Second, the presence of human bodies (with all that water), metal, the seats themselves, and other objects will wreck havoc on radio wave propagation.
These
[1][2] discussions of indoor positioning with beacons hit on some of the inherent difficulties. It's not going to be anywhere near exact and will require continued usage of CPU cycles. There's a pretty big margin of error no matter how you approach it, which is a problem for our use case. Cars are small, confined spaces. Is the phone on the driver's side, or is it in the passenger's left pocket? What if it's sitting in the center cupholder? Or what if the driver just tosses it on the passenger's seat? There are a ton of different placements, and since phones can be repositioned, there are all sorts of ways I can think of that a driver could manage to use their phone while driving.
So what about
using trilateration to determine the approximate distance to fixed, very low-power bluetooth or NFC beacons in the car, such as iBeacons? If a handful are mounted behind the car's headliner and throughout the car, you could calculate distance to them to determine (1) that the phone is in fact inside an actively moving vehicle; (2) whether the phone is located near the driver.
Since we're already assuming the involvement of the car manufacturer in this process (and I'm sure they'd be ecstatic to spend a bit more per car to make this work... :sarcasm

, we could also assume that they implement a bit of logic using existing sensors (weight & seatbelt sensors) that determine whether the passenger seat is occupied. If it isn't occupied, the beacons could be used to signal the phone to use the alternate interface while the vehicle is in motion/motor is on/etc. No passenger, no need to worry about working anything else out.
And while you might use
multilateration to measure the difference in two beacons (say, one on the driver's door and one on the passenger's), that opens up a whole new can of worms. By having to plot the device's location on a curve relative to the two fixed signals, you're forcing the car manufacturer and phone developer to make a decision that could open them up to increased liability if they get it wrong when deciding "this is the driver" versus "this is not." Both are forced to implement something where they have only limited knowledge and zero control over the work of the other. The lawyers would have a hissy fit. And they'd be right to do so.
Anyhow, the driver can always turn off the bluetooth and NFC radios. Then they get to sidestep all of the annoying work you just did to implement a system with a margin of error practically the size of the car itself. Oops.
3) Tweak the bluetooth specs to include an extra identifier for car-based connections. If it's a car, or a car audio product, then when the phone connects, it gets locked-out. But if you don't connect the phone, then the check is sidestepped altogether. And you'd have to wait for new products to implement this change, anyhow. For the car industry, assume a decade or so and go from there.
4) You go nuclear. If the phone is moving past a certain speed, it gets locked-out entirely or the alternate interface is loaded up. But this sucks, because there are a ton of other scenarios. Passengers are obviously caught in this trap. A person on a boat, or a bus, or a train, or a plane, or a bike, or riding a horse are out of luck as well. Some of those could be avoided through location data as well, but not all. And we're back to killing the battery. Plus, a minimum speed assumes that there won't be distracted driving *under* that speed. What about in a residential housing plan, or crawling through morning traffic, or going 15mph in a school zone?
Well, maybe you implement a pop-up alert. Click here to continue if you are *not* driving, acknowledging and accepting liability for your actions. But that's annoying, and you'd need to trigger it every time the device is unlocked. Cue the angry customers. And if you're going to text and drive, what's one more tap to you anyhow even if it is logged in a system log that can be subpoenaed if you're in an accident?
******
Sarcasm aside, while you might feasibly be able to implement such a system that's capable of locking-out devices on the road while differentiating between driver and passenger, it won't be a very good system. It'll either be sloppy, overly-complex to an incredible degree, or will be easy to bypass with almost zero effort.
The better solution to distracted driving is education and possibly alternate contextual interfaces (CarPlay, Android Auto, etc.). But neither will make the problem go away entirely, and that's damned depressing when you think about the very real consequences for innocent people on the roads.
Actually, I take that back. The only real solution will be self-driving cars. Remove the human from the equation entirely, and the distracted driver disappears.