There is not a law that grants you access, or denies you access, to these funds across the board. It will depend entirely on what the specific plan documents for your former employer's specific plan says about distribution. If the plan does not allow distribution at this time, or for this reason, then they not only CAN legally deny access, but they MUST deny access. They would be in violation of the law if they allowed you access in disregard of the plan documents. The employer does NOT have the option of making an exception for you - the IRS is very strict that the plan documents be adhered to regardless of how urgent your need.
FYI - it doesn't matter who put the money in; employee AND employer contributions are subject to the plan distribution rules. Employee contributions are always 100% vested - they cannot be lost. But that is not the same thing as always being able to access them at will - they are still subject to distributions limitations.