If correctly structured, probably
First, there is no issue with escorts in Canada. If you are in Toronto and need a plus one for the big gala dinner, you can hire a date provided sexual gratification is not part of the deal. An NDA as part of that sort of contract would be fine.
Similarly, in jurisdictions where sex work is legal, there’s also no problem.
So, we will just focus on contracts where one of the fundamental obligations involves an illegality. This doesn’t have to be prostitution, it could be a contract for murder, or the supply of illicit drugs, or the supply of unpasteurised milk.
One of the requirements for a valid contract is legality of objects. A contract for an illegal purpose is void. See What is a contract and what is required for them to be valid?
Therefore, an NDA that was a term of such a contract is also void.
However, an NDA that was a separate contract, even a collateral contract, would be enforceable because NDAs do not have illegal objects.
This can probably best be illustrated by an example. Let's imagine there is an establishment where people can go for food, drink, entertainment, and socialise - we'll call it the club. As part of the contract for using the club or being an employee or supplier to the club or its patrons, there is an NDA not to reveal anything that happens in or is associated with the club. There is no reason to believe that this NDA would not be a valid and enforceable contract - subject to the normal laws that limit such agreements.
Now, if visitors entered other agreements that were void, with each other or with the club - such as for the supply of sex or illegal drugs - this would not, on its own invalidate the NDA contained in the other contract.
If a court decided that the whole operation was a sham and that the club was merely a front for a brothel, they may find the original contract is void as being against public policy or, it quite likely may be an irrelevancy, because people engaged in a joint criminal enterprise have very few rights against one another anyway. However, if the club is primarily a legitimate business, then there would be no reason to impugn the original contract.