So as I understand it, if you choose a random parameter and fill the entries of a matrix with that parameter, you get a random matrix. I was wondering if there are some general conditions under which a matrix can be both unitary and random such that the unitarity condition is now being satisfied.


I am aware that there are already examples of random unitary matrices which can be chosen from the Haar measure, so perhaps this question is related to the concept of the Haar measure?



Random Unitary Matrices
I understand your question as asking for a constructive method to sample uniformly from the unitary group $U(N)$ or orthogonal group $O(N)$, where "uniformly" is understood in the sense of the Haar measure. A simple method starts from an $N\times N$ matrix filled with independent Gaussian random variables [complex for $U(N)$ and real for $O(N)$]. Then orthonormalize the columns via [Gram-Schmidt](https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process) and you're done.


For a more efficient approach, see [How to generate random matrices from the classical compact groups](https://arxiv.org/abs/math-ph/0609050) by Francesco Mezzadri.


The construction is implemented in Mathematica in the routines [circular unitary ensemble](https://reference.wolfram.com/language/ref/CircularUnitaryMatrixDistribution.html) for $U(N)$ and [circular real ensemble](https://reference.wolfram.com/language/ref/CircularRealMatrixDistribution.html) for $O(N)$.  

Caution: the socalled [circular orthogonal ensemble](https://reference.wolfram.com/language/ref/CircularOrthogonalMatrixDistribution.html) does not sample from $O(N)$ but from the coset $U(N)/O(N)$.


