How should I adress (grammatically) a referee whose gender is unknown?
The use of singular they, as in your second option,
- We agree with the referee on their comment...
is perfectly appropriate. You can also use some other alternatives, most notably he/she, as in e.g.
- We agree with the referee on his/her comment...
I would discourage you from using some of the more niche alternatives, such as Spivak pronouns, in correspondence that's this formal.
On the other hand, your first alternative (We agree with the referee on its comment...) should not be used under any circumstances. It is considered extremely rude by native English speakers, since it reduces the referee to the level of an inanimate thing. If you use it you can hope, at best, to come off as someone with a very poor command of the English language.
Why not
We agree with the referee's comment.
(I gathered my answer from the question "Agree on" vs. "agree with" vs. "agree to" on English SE)
In "unknown" gender situations, I use constructions like s/he and his/her.