It is not enough to put the figure inside the rotation because the label can only be attached to an element in content mode. So you have to do it like this:
#rotate(
-90deg,
reflow: true
)[
#figure(
table(
columns: 2,
[T], [1],
[T], [2],
),
caption: [A caption]
) <mytable>
]
Reference to mytable @mytable
Output

Please use code blocks in your posts like this:
```typ
your code goes here
```