I parked my car at one of the out-of-the-way campsites by the Lamar Valley - not actually in a designated camping spot, but in a little dirt parking lot that was at the entrance to the campground (I think there was also a trialhead there). I don't know if that was against park rules or not, but it was after dark by the time I parked there and soon after, I was joined by two other cars who did the same thing. I was up with the dawn and drove out onto the main road just in time to see a herd of bison crossing the road in front of me. Very impressive.
Yes, it is illegal to park overnight, even if leaving early, at a trailhead. No telling what your fine would have been had the rangers caught you, and they do patrol at night.