Before Google announced the Pixel 2 and Pixel 2 XL, it pushed a new app listing to the Play Store that offered some details about the rumored always-on music ID feature. It turns out there's another interesting tidbit in that listing: the Pixel 2 will be able to automatically toggle on Do Not Disturb mode when you're driving.
The listing in question is called Pixel Ambient Services, which is a nice, vague name. Two of the screens are related to the music feature, but one of them references DND mode. There's a "driving" settings screen as part of this services app. When you turn that on, Do Not Disturb will activate when you are driving (based on the phone's sensors).
The drawback with this feature is that it most likely can't actually tell if you are the one driving. The sensor input from the phone will look the same if you're a passenger as if you're behind the wheel. It's also supposed to use Bluetooth to determine if you're in the car, so perhaps you'll also need to be connected to the car for this feature to trigger. There will be a toggle, so at least you can turn it off should this feature not work the way you want. We'll be able to test this and see how accurate it is when the Pixel 2 is available.