Do we create the backlog before concluding the contract with the client?
The backlog is not something that you create and then is static. The backlog changes - items are added, removed, and reordered - throughout the effort. Unless there is some legal or contractual reason not to, there's nothing to prevent starting the creation and refinement of the backlog before any kind of formal contracts that may be necessary are in place.
However, there may be some risks here. First, the developing organization may have to fund this effort without a way to recoup the costs from the client. Second, depending on the nature of the relationship, it may not be allowed to interact with the client to get feedback on the backlog state until after the contract is finalized.
I'd suggest that the best answer is no. Creating and refining items on the backlog is part of business-as-usual - part of the ongoing collaboration between you and the client. Presumably that collaboration starts when the contract starts. Creating the team would have to come first and then the team can have its initial Sprint Planning meeting.
Creating a backlog in advance might give the wrong impression by suggesting that the PO and the rest of the team don't really "own" their backlog.
As any work that you perform before the contract is finalized may be lost, you should constrain yourself to only those work items that are necessary to secure the contract.
If building an initial backlog helps to create a better estimate and to convince the customer that you're qualified to execute the contract, it might be fine. Otherwise, it's just premature work that is probably not billable and may be lost if the contract isn't entered.
The corporate managers who are attempting to secure the contract should be the only ones to tell you how much planning and advance work you should be doing before the ink is dry ... if any. Because, if for any reason the contract falls through, the entire cost of the effort that you spent is a "sunk cost." They will be obliged to pay your salary out of their own reserves, so don't spend their money unless they tell you to.
You might well be asked to predict what the course of the now-hypothetical project might be, to assist the contract-makers in filling in the proper numbers (so that everybody gets paid), but you should not spend any effort (money ...) without express authorization from the managers and negotiators. You should give them exactly what they ask for – no more and no less. No contract is real until it is signed, and you're not the ones holding the pen.