[ty] Fix Gitlab codequality output format for empty diagnostics (#22833)
## Summary
Closes https://github.com/astral-sh/ty/issues/2617
This PR fixes the behavior of `ty check --output-format=gitlab` when
there are no diagnostics.
Previously, the output file was empty (0 bytes) if no errors were found,
but GitLab expects an empty JSON list (`[]`) in this case
(https://docs.gitlab.com/ci/testing/code_quality/#code-quality-report-format).
As stated : "The file you provide as [Code Quality report
artifact](https://docs.gitlab.com/ci/yaml/artifacts_reports/#artifactsreportscodequality)
must contain a single JSON array."
Now, when the GitLab format is selected and there are no diagnostics,
`[]` is written to the output file, ensuring compatibility with GitLab
CI/CD.
## Test Plan
Ran `ty check --output-format=gitlab` on a project with no errors and
verified that the output file contains `[]`.
Ran `ty check --output-format=gitlab` on a project with errors and
verified that the output file contains the expected JSON diagnostics
list.
Confirmed that other output formats are unaffected.
---------
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>