I tried to enter a shop that closes at 11 p.m. in France, at 10:30 p.m., and the store security guard prevented me from entering. Does he have the right to? If not, what could I do to go in? What do I risk if I force the passage?
I do not know the particular legal environment in France, but in general the shop is private property and the owner decides who may enter and who may not. You have no right as such to enter somebody else's property against their will. Doing so would at least be classified as trespassing, possibly more serious considering you mention using force to enter the premise.
The store can set its "opening times" any way it likes.
To avoid employees having to work too long, it is not uncommon that tills are closed at closing time, so you come too late, you can't buy the things you want. The till can also close before closing time if they believe they can handle the current customer before closing, but not the next one.
And of course since it is pointless to have you filling your shopping trolley when you are too late to pay for the goods, they can keep you from entering the store significant time before closing.
Forcing passage is a legal risk that I wouldn't take. If they are nice they throw you out. If they are not so nice they call the police. Now if you are a tourist and that happens to you (because residents know how it works), getting arrested in a foreign country is something that can really spoil your holiday.
Does he have the right to?
Maybe, depending on the meaning of "right", and if he (or the store) can invoke a legitimate reason (or such a reason can be presumed from the circumstances).
Without a legitimate reason, the store risks being in violation of the law against refusal to sell under consumer protection law.
At the same time, a person entering a private property without specific title (when the invitation to enter, usually inherent to commercial stores and non-fenced properties, is denied or terminated) who refuses to leave may be removed forcefully by judicial police officers (but not by security agents) on the complaint of owners. Your consumer dispute with the store does not normally change this, absent previous judicial orders (e.g. if the court had ordered the shop to conduct business with you); although the removal may constitute the evidence of refusal to sell and may be an aggravating factor if it happens after a previous finding of refusal to sell. Under certain circumstances you may also demand civil damages before a court; but at the moment, the police officers usually defer to the owners in a shop (occupants in an apartment is different).
To justify a refusal to sell, if the store had a sign explicitly saying "last entry at 22h30", this would almost definitely constitute a legitimate reason, within their freedom to set opening and working hours (subject to planning and labour law) and such display serves as a contractual base. Contractual bases are legitimate reasons if they are clearly displayed and not abusive.
If not, the store may invoke a legitimate reason, or the judge can also assess the circumstances on their own initiative. For example, refusing entry to a big store at 22h55 is more easily justified. This will depend on other circumstances, for example, if a restaurant refuses service half an hour before the closing time, it is usually recognized as a legitimate reason. And if a shop will close earlier than announced due to e.g. employees will leave, this is also a legitimate reason (but doing so everyday may breach certain false advertisement laws if the advertisement of false hours create an anti-competitive advantage).
If not, what could I do to go in?
Even if you may have a legal right to be sold an advertised item, the proper avenue to exercise such right is through civil courts, the public prosecutor or the departmental competition and consumer agency (Direction départementale de la concurrence, de la consommation et de la répression des fraudes).
What do I risk if I force the passage?
While trespassing is not an offence in itself in France, trespassing using ruses, threats or any physical means is an offence.
Insults may give rise to a legitimate reason for refusal to sell, and severe insults may lead to prosecution and civil damages. The consequences become immediately much more serious if you declare physical threats or actually use physical means to try to enter, as these are more serious offences that can lead to prison sentences and a criminal record.
I think the core question here is if they denied access to you specifically and alone, while admitting others, or if the store closed earlier than its posted times, and denied entry to everyone equally.
In some jurisdictions (I am not sure of France in particular), stores are required to publish and keep their business hours. Except in rare extenuating circumstances, they can face penalties for opening or closing beyond their published hours. This is typically a matter for the governmental body that licenses and regulates business, often a Secretary of Commerce, or Business Licensing, or Consumer Protection agency.
But if they denied access to you specifically, it becomes a question of why?
Were you drunk/disorderly/rude? Do you have a history with this store?
Then they probably had good reason to refuse service.
If however it can be shown that it was for a protected reason (you were wearing a religious symbol, or in a wheelchair, or of a particular race), then their denial of entry would likely be discriminatory.
Your post just did not have enough details to provide a clear answer.
However, UNDER NO CIRCUMSTANCES should you "force the passage". Then you would clearly be at fault, and liable.