Can oscilloscope ground be connected to the signal generator ground?
Yes, and most oscilloscope grounds are connected to signal generator grounds if they are built in. It depends on the result you want, there may be advantages to having them separated to avoid common mode noise. Make sure your ground is low enough resistance to avoid common mode noise.
What happens if these grounds are then connected to different potentials when in use? Nothing will happen provided that you connect ground to ground. If the ground is at a different potential (ie lets say one is 10mV above the other) then current will flow between the two grounds.
If device is powered by 5V external power supply (like phone charger), does this mean that device ground is "virtual"?
Isolated = virtual. Isolated means the ground is not connected to mains ground, it also means you can 'float' the ground. This is usually done via a transformer.
Keep in mind that volt meters don't have a ground, you measure the potential between any two points, and most multimeters these days will do 100's of volts. A multi meter is a differential measurement and not connected to ground and is isolated.