If the bike is upside down and the brake levers are pushed then you can force air into the system resulting in the issue you are seeing.
There are a number of things you can try to restore function but if they don't work then a bleed will be necessary.
With the bike the right way up repeatedly pull the brake lever, this can encourage the air back out into the reservoir where it belongs.
If this doesn't work then zip tie the brake levers to the bars to pressurise the system, leave overnight and then try the first step again.
After that it's time for a proper bleed to get the air out of the system. How you do this and what you need depends on the model of brake and may involve special sryinges and adapters at one extreme and a bit of tubing and a jam jar at the other.
If the brakes haven't been bleed for some time, years not months, then a bleed might be a good idea anyway.