How are pilots alerted to the publication of a NOTAM affecting their flight while in-flight?
In the case of the 777 (or any flight operating on an IFR flight plan) it is ATC's (and the pilot's) responsibility to vector the flight around restricted airspace. In the event of pop-up NOTAM's, ATC will do their best to inform you, especially on an IFR flight plan. The key is you should be talking to somebody, or at least listening in. I have a feeling though that you want a little more...

Flight Information Services (FIS-B) provides weather, text, graphical weather, NOTAMs, ATIS and other information to aircraft in flight over the UAT link. ADS-B (ADS-B Out mandated for all aircraft in controlled airspace by 2020 in the US) will be able to provide similar data to aircraft in flight all the way down to small GA (if they have ADS-B In capabilities, or ADS-B receivers like Stratus).

So the crew of your hypothetical 777 will be notified multiple ways: 


ATC will notify them about the need to vector around restricted airspace.
ATC will notify them about the closure of an entire destination airport as filed
NOTAMs will pop up on the FIS-B display in the cockpit
The ATIS or automated information broadcast will be updated to include NOTAM'd airport or runways
Crew will see the FIS-B display when they check destination airport weather/closures enroute
At the very least, ATC will notify the flight on approach ("Airport is currently closed, please continue to the filed alternate" or something like that)


Now, on the flip side let's say that you are a J-3 Cub with no radio humming around to your local uncontrolled field. The field was just closed due to a water buffalo migration and NOTAM'd out of service until the beasts can be removed from the property. You are on a 5 mile final and all the water buffalo are hiding in the woods next to the runway...

If you land you've violated the NOTAM and airport closure. This may warrant a call to your FSDO but you will probably be able to explain that the NOTAM wasn't active or identified prior to departure and they'll let you off (and the next thing you should do is go buy a handheld radio). At the very least you should make a report in the Aviation Safety Reporting System (ASRS) in case somebody raises concerns.

Either way if possible the FAA recommends a 4 hour minimum notification time for closures that can be planned. Why 4 hours? Most GA aircraft have about a 4 hour endurance and most domestic flights are less than 4 hours long. Obviously not everything can be planned, but ATC will work with aircraft in flight to disseminate the information as required.