How to write trace(inverse(X)*inverse(X)) in the objective function?

inv_pos is applied element-wise, It is not any kind of matrix inverse.

What you claim to know about it being convex is not true.

However, if X is psd, so is X^2. If you declared a variable X_squared semidefinite, you could use trace_inv(X_squared). But it is not convex in X.

Whether declaration of X_squared rather than X will work for you, depends on whether X is separately needed elsewhere in your problem. Note, writing X >= 0 is redundant (in SDP mode) if X is already declared semidefinite in the variable statement.