canada
The specific example is likely not a contract
As phrased ("if you break into this house, you agree to paying the owner a one million dollars access fee"), I am doubtful there is a contract here.
The promise to pay one million dollars is not secured by consideration going the other direction. The wording does not say "in exchange for permission to access, you agree to paying... ." Instead, the wording contemplates that what would be occuring is "break[ing] into this house." That is an act without permission.
Instead, I read this as an attempt to unilaterally hold somebody to an obligation without a contractual basis for it.
But if it were a contract, its enforceability would turn on an unconscionability analysis, not a "penalty" analysis
If the wording instead were phrased as a price for permission to enter, accepted via conduct, this would much more clearly be a contract. For example: "In exchange for permission to be on the premises, you agree to pay one million dollars. You accept this contract if you enter onto the premises."
The law in Canada and the U.K. substantially differs from the law as described by ohwilleke (see point 2) in relation to penalties.
If the burglar accepts the contract by entry, yet chooses to not pay, the expectation damages would be one million dollars. The standard measure of damages for breach of contract is expectation damages, "measured according to the position which the plaintiff would have occupied had the contract been performed" (Atlantic Lottery Corp. Inc. v. Babstock, 2020 SCC 1 at para. 50). In this case, had the burglar performed their side of the contract, the homeowner would have one million dollars. There is no question as to what the expectation damages are in this circumstance.
This is not an issue of a "penalty" for breach. When the agreement is to pay a particular sum, it is not a penalty to seek that sum.
Dunlop Pneumatic Tyre Co., Ltd. v New Garage and Motor Co., Ltd. [1915] AC 79 (UKHL):
It will be held to be a penalty if the breach consists only in not paying a sum of money, and the sum stipulated is a sum greater than the sum which ought to have been paid. This though one of the most ancient instances is truly a corollary to the last test. Whether it had its historical origin in the doctrine of the common law that when A promised to pay B a sum of money on a certain day and did not do so, B. could only recover the sum with, in certain cases, interest, but could never recover further damages.
The issue that an excessive "liquidated damages" clause presents is when it is not a genuine pre-estimate of the expectation damages in the case of a breach. Such an excessive liquidated damages clause would instead be considered an unenforceable "penalty" clause. But in the hypothetical contract here, one million dollars is exactly the expectation damages: one million dollars is what was promised; and one million dollars is how much richer the homeowner would be had the contract been performed.
It is also recognized that agreement to pay a sum on the happening of an event, no question of penalty arises. See Chitty on Contracts, 26th ed., p. 1831, stating that for a plaintiff to claim the agreed upon price does not even raise the penalty issue:
The law on penalties is not applicable to many sums of money payable under a contract. Thus, it is not relevant where the plaintiff claims an agreed sum (a debt) which is due from the defendant in return for the plaintiff’s performance of his obligations, or which is due upon the occurrence of an event other than a breach of the defendant’s contractual duty owed to the plaintiff.
The penalty doctrine "is not designed to relieve a party from the consequences of what might in the event prove to be an onerous or even commercially imprudent bargain" (Doman Forest Products Ltd. v. GMAC Commercial Credit Corp. - Canada, 2007 BCCA 88, para. 122).
For such relief, one would have to turn to the doctrine of unconscionability (point 3 in ohwilleke's analysis). I agree this would be a high bar to meet.