If you're buying the property from a bank, it's their responsibility to get the previous owners out unless they have specifically stated that's not their problem.
You can consider getting someone to rehab throughout the home during normal construction hours at decibel levels not appreciable. Consider a very slow handyman who likes to hammer deliberately.
Erect a large and difficult to remove political sign on the roof or lawn for a candidate your squatters would not appreciate, most likely a conservative candidate not approving of freeloading, but don't be too sure. Obamacare for All or Santorum My Saviour can be effective for the right person. Observe their shoes and bumper stickers for more clues.
While you can not force them to leave, you should consider moving in with them, and putting an ad on Craigslist for obnoxious roommates who want a free place for a few weeks. No matter how obstinate your squatters appear, a few mornings of your new roomies picking their noses naked in your kitchen drinking milk out of the jug we'll turn most people off. You'll want to consult a lawyer on this one, but if you are the owner, and they are not in a lease, the co-habitation might be feasible since most people would never think of it, hence the lack of public information on it.
Consider occupying the attic or basement after you watch Pacific Heights.
If it's a multi-unit or two flat, three flat kind of building, fill the other apartments with those same Craigslist characters and make sure to install a loudspeaker in the building that plays the Marines bugle wake up call every morning before sunrise.
What does your attorney say? What does the listing agent say? What does your contract say regarding possession at closing? YOU NEED SOME ANSWERS and quickly. If your contract states possession at closing and they're still there I personally would not close. It could take you months and some money to evict. Let us know what happens.
I've had people extent actual evictions for months - one for six months. They claim a hardship, medical issue(s).
You have these options:
1) Tell them that you own the property. Ask them to leave and see if they do. This probably won't work but it's worth a shot.
2) Have them sign a lease and pay you rent.
3) You pay them relocation assistance (use a written contract and pay them after they move out)
4) Evict them and have the sheriff remove them.
I would advise paying them relocation assistance (cash for keys). Evictions take a long time and can be messy; they may also be bitter and cause damage to the house. Usually a condition written into a relocation assistance contract is that they don't damage anything (other than what is already damaged) and they move out everything and leave the property in broom-clean condition. It can cost anywhere from $500 to $5000, and it's between you and the tenants.
You will need to wait until you own the property to do these things.