The first time you don’t get a job because of a reference you gave you learn a lesson. If it ever happens again, it’s on you.
If a company is proactively contacting people you don’t give them contact information for, that’s not requiring references — which is the process I (and the comment I replied to) was talking about. If a company knows where you’ve worked, they can contact them if they want.
If they proactively contact someone as part of their verification?
In the past, I’ve extended the time I was at either the company before/after and then leave the one in the middle off. Smaller gap is easier to explain and you just need a coworker at the one you stretched to cover for you - or have it be somebody who wasn’t there during the time you added. You can also just say you did the “freelance” thing and then talk about whatever you want.
I’ve also just been 100% honest and said, “I didn’t like this job and left on bad terms. I’d rather you not contact them.”
Just have to read the situation and make your best guess as to what is going to get you the job.