Answer: It depends on your rear derailleur capacity.
The ability to use TRS or XCX cassettes with a 2x system is strictly dependent on the capacity of the rear derailleur. Your derailleur capacity is the maximum amount of slack chain the rear derailleur cage can handle. The more potential slack, the bigger a derailleur cage you need. 2x systems generally require more capacity than 1x systems.
Capacity is found by taking the difference between your largest and smallest front and rear gears.
(Difference between tooth count on smallest and largest chainring) + (Difference between tooth count on smallest and largest cassette cog) = Capacity.
For example, if you are running 22-36 chainring and 9-39 cassette then: (36-22) + (39-9) = 44. This means you need a derailleur with a capacity rating of more than 44 for your 2x system to function correctly.
Please reference your derailleur models technical specifications to find information about specific model capacity.