as a witness. You secretly disapprove of the thing taking place
Does this actually invalidate the document (as not properly
No. In regard to the substance of a contract, witnessing does not imply, entail, or require approval thereof by the witness. The meaning or relevance of a witness's signature is nothing more than him or her certifying that the act of "2+ other parties entering a contract" took place indeed.
And are you committing a crime by doing it?
I highly doubt it, regardless the country or jurisdiction. The witness's [bizarre] act of acquiescence falls short of criminal conduct such as (1) forging someone else's signature, or (2) fraudulently "acknowledging" the presence of the contracting parties when in fact at least one of them was totally absent.
Only if the witness subsequently acts in a way that hinders the purposes of the contract, thereby causing harm, the harmed party(-ies) might sue the witness for tortious interference with business or relation (or its equivalent in other non-U.S. jurisdictions).
For instance, suppose a contract-based transaction requires involvement by a third party, who is hesitant to perform the transaction because suspects that the witness's signature was forged. That suspicion may prompt the third party to inquire of the witness whether he actually signed as witness to the contract. If the third party rejects the contract-related transaction due to the witness's [false] denial, the harmed party(-ies) in the contract may sue the witness for any losses (examples: bounced checks, costly delays, missing of deadlines, provable loss of business opportunities) that his false denial caused.