This answer uses the term "squatter" to refer to someone who broke in a home or otherwise entered with no legal title whatsoever. Inhabitants that entered legally but stayed illegally (such as a tenant that failed to pay rent, or a tenant’s relative staying against the will of the tenant and/or landlord) will be deemed "overstayers". The distinction has some teeth in French law.
Changing locks is illegal
A quick online search turns up multiple sources such as this one that claim a landlord changing locks in a rented house is guilty of home violation (CP, art. 226-4, cited and discussed below). I am not entirely sure that is correct without reference to a court case on that point, but assuming it is, it applies to squatters as well: the statute refers to inhabitants, which includes overstayers and squatters (as well as legal tenants).
That’s it for the question asked, but the post also covers other aspects which are worth covering.
"48 hours" does not exist; flagrance does
As a very general rule, the police is allowed to do more things than usual when acting "on hot pursuit" of a recent or still-occurring suspected criminal activity. That is an exception to general principles, justified by the need to prevent irreversible harm and/or undue difficulties in the collection of evidence. Similar exceptions exist in other countries.
The exact definition of flagrance is in CPP, article 53. It is limited to eight days (which is more than 48h), but that is an upper bound on the duration of the enquête de flagrance ("hot-pursuit" inquiry).
It is possible that police (either in general, or in certain cities) are under orders to not pursue flagrance inquiries beyond 48h, either as an expense-cutting measure or because prosecutors have found it hard to justify late-start flagrance procedures in court. Similarly, police might be under orders to not pursue squatting cases with zeal when the landlord does not live in the squatted home, because that is considered a less urgent case.
I assume, but have not searched the jurisprudence hard enough to be sure, that it is legal for police to remove the occupiers and their stuff from the premises during an enquête de flagrance. (There is little doubt that the occupiers can be taken to the police station, but it is less clear to me that removing their belongings is justified by the necessity of the enquiry and/or prevention of further crimes.)
Criminal statute for squatters
The basis for criminal prosecution of squatters is CP, art. 226-4:
L'introduction dans le domicile d'autrui à l'aide de manoeuvres, menaces, voies de fait ou contrainte, hors les cas où la loi le permet, est puni d'un an d'emprisonnement et de 15 000 euros d'amende.
Le maintien dans le domicile d'autrui à la suite de l'introduction mentionnée au premier alinéa, hors les cas où la loi le permet, est puni des mêmes peines.
Entering into another’s home thanks to maneuvers, threats, acts of violence or coercion, except when allowed by law, is punished by one year of prison (...).
Remaining in another’s home, following the entry described in the previous paragraph, except when allowed by law, is punished similarly.
Evicting squatters based on flagrance
The enquête de flagrance is only allowed for crimes carrying a penalty of at least one year of prison. We’re in luck, that’s the penalty of CP 226-4.
The second paragraph was added with the specific purpose of allowing the flagrance procedure to apply past the short delay after entry (link to the parliamentary file), by making remaining in the home a continuous violation.
Administrative eviction
An administrative eviction procedure is possible since 2007, under these conditions.
That procedure is rather quick (24h notice to occupiers) but it requires the support of the préfet, and is therefore limited by the availability of law enforcement resources, how clear-cut the case is, etc. (Yes, the law says "le préfet doit..." (the prefect must...), but there is no real recourse against him/her not doing it.)
Standard eviction
The standard procedure is indeed relatively long. Here is the relevant section of the Code des procédures civiles d'exécution. It requires a court order, then a 2-month notice period for overstayers (not for squatters), then police intervention. Furthermore, the two-month delay can be extended by up to three months "due to the time of the year or atmospheric circumstances" (in practice, during winter).
The 2-month period for overstayers, and its winter extension, is obviously a political compromise between avoiding to kick out families into misery and enforcing property rights. However, securing a court order before that often costs much additional delay.
Civil claims
The landlord may pursue monetary claims against the occupiers on various grounds (lost rent, the costs of going through the expulsion procedure, damage to the home etc.). While they will most likely succeed at court, squatters are usually not the sort of people with large financial resources; such procedures are usually not worth it.
Some political commentary
...which I will indulge in, because neither Le Figaro nor their leftist counterparts usually present the legal situation honestly.
One should definitely separate the discussion of squatters and overstayers and not lump them together. Whether the two-month protection for overstayers is "surrealistic" is in the eye of the beholder. I would certainly find it reasonable to modify that delay to be up to two months, left to the judge’s discretion depending on the particular situation. One could also argue that no-fault evictions (i.e. a landlord wants to stop renting, without fault from the renter) are too hard in France (but that’s not really relevant to the squatter case).
Needing a court order to evict someone is certainly not a French peculiarity. I would argue that some judicial process with a contradictory debate is a necessary protection against undue evictions. The time it takes to secure a court order is a legitimate problem, but that is due to the abysmally-low justice budget, not a problem of overbearing legislation.
Similarly, police not vigorously pursuing squatting cases is not due to legal barriers (as explained above, the flagrance procedure is available without time limit since 2014), but to underfunding and/or a choice of enforcement priorities.