VAR (Video Assistant Referee) is being implemented in the World Cup 2018. Sometimes, an action occurs (e.g. a penalty), but the referee does not think in the first instance that it does so. Then, as the game continues, the referees at the VAR room tell the referee in the field that there was actually a penalty.

Now, imagine that as the ball is in play, and the VAR is being reviewed, one of the teams scores. If then the VAR considers there was a penalty, would the goal that just happened be reversed? The website linked above does not mention this particular (and yes, very unlikely) case.

The referee may not change a decision on realising that it is incorrect or on the advice of another match official if play has restarted or the referee has signalled the end of the first or second half (including extra time) and left the field of play or terminated the match.

Technically, a team should not be allowed to score a goal if they have committed an offence since the last restart of play. The VAR adds a new dimension in that decisions that all on-field officials have already ruled on may end up being changed, but the underlying principle is still effectively the same.

Consider the following example that could already occur without VAR (and obviously at a level where the match officials don't have comms gear):

The red team loses the ball in the blue team's penalty area, with a red striker landing on the ground after a strong, but fair tackle.

The blue team clears the ball to the blue attackers, who end up in a strong attacking position

The blue goalkeeper takes exception to the red striker, believing he has dived, and kicks him within blue's penalty area.

This is flagged by the AR in blue's half, but the referee misses it as he is in position to monitor blue's attack and has his back to the AR.

Meanwhile the blue attack develops, leading to a goal.

Before restarting play, the referee notices the flag from the AR, cancels the goal awards a penalty kick to red, and sends off the blue goalkeeper for violent conduct

As you can see, nothing has really changed here, other than the possibility of far more decisions being changed after they were initially decided on and/or missed. Having said that, the example provided in your question is unlikely to occur - according to IFAB's VAR Protocol:

If the referee wants a review when play has not stopped, play should be stopped as soon as it is in a ‘neutral’ area i.e. when neither team has a good attacking possibility.

Unless it is an extremely quick counter attack, the referee would probably stop play before a goal was scored up the other end.

If the goal was scored by the team who should be awarded a penalty, the goal should be awarded. This is standard officiating practice in the case of an advantage to the attacking team.

If the goal was scored by the team who committed the foul and should concede the penalty, the section of play is likely to be ignored and the penalty given, as this would be significant gain from their own offence.

Note that it is extremely unlikely the second case would arise. The assistant referee would probably flag, or the referee would find some reason to stop play, and allow the VAR review to occur at the stoppage.

This answer is based on my personal experience as an official at a high level. Unfortunately, there aren't many publicly accessible documents that pertain to most officiating practise - it's largely ad hoc discussion and privately held documents.