Computation of matrix-valued formally orthogonal polynomials and applications