I enabled developer mode on my Pixel 2, and with this On in System > Developer options there is a Default USB Configuration setting I can set to File Transfer (or USB teghering, MIDI, PTP, or No data transfer).
This is obviously hugely risky if you forget, stick your phone into some random...