Before we tackle the hard problem outlined above, let's solve the easy problem of pedestrians (bikers, scooters, skateboarders, etc.) traveling on highways and crossing traffic in undesignated places. I can't tell you how many times I've had pedestrians impatiently run across the roadway in front of my car.
I'm not sure one problem is easier to fix than the other. They both seem to come from people acting irresponsibly to arrive earlier at their destination, probably combined with an infrastructure to nudge towards that behaviour.
Changing behaviour with a penalty isn't terribly effective unless enforced in such a way that it is incredibly privacy-invasive, more effective is changing the layout of the streets. But I wouldn't be sure that that is easier to fix on the pedestrian side than on the vehicle side.