It would be very unusual for the Church to perform a marriage that is not legal. In the countries where a civil marriage MUST be celebrated first, the Church will usually not perform the ceremony without a copy of the civil marriage certificate.
In countries where the Church wedding is also a legal wedding, the Church won’t marry someone without the proper licenses.
But, for good reason, the Church will perform a secret marriage, one that is not recorded in the usual registers and which remains secret until the couple decides otherwise. Defrauding the government of social security money doesn’t qualify as a good reason. One of the valid reasons given is when the laws of the country prevent the legal marriage but those laws are contrary to God’s law (the example given was the marriage of an interracial couple when the State forbids such a marriage).