That depends on the context, which unfortunately was not provided in the question. So your question cannot be answered because you did not provide enough information. (Btw: The same problem would arise if the sentence was in English. Also in English you need the context to tell whether the pronouns gender is correct or wrong.)
In principle, in German each personal pronoun must always agree with the gender of the noun to which it refers. The question is therefore: to which noun does the pronoun refer?
(In German, there are many different types of pronoun. When this answer refers to a "pronoun", it always means a personal pronoun.)
Option 1: The pronoun refers to a noun that appears in the same sentence.
The noun usually comes before the pronoun, but it can also come after it. The order noun-pronoun is much more common than the reverse order.
Sebastian hat 14 Freunde und Sandra hat sogar nur 8 Freunde. Beide haben so wenige Freunde, dass sie sich die Namen ihrer Freunde sehr gut merken können. Aber Tom hat mehr als 700 Freunde. Tom hat so viele Freunde, dass er sich nicht alle Namen merken kann.
Sebastian has 14 friends and Sandra has only 8 friends. Both have so few friends that they can remember their friends' names very well. But Tom has more than 700 friends. Tom has so many friends that he can't remember all their names.
This example is about how many names individual people can remember. The pronoun therefore refers to the masculine noun "Tom", which is the name of a male person, so the pronoun must also be masculine ("er").
Option 2: The pronoun refers to a noun in a different sentence.
(Here, too, the pronoun usually refers to a noun in a previous sentence. The other order is also possible, but rarely used.)
Tom hat sein neues Handy verloren, und als Ersatz hat ihm sein Vater ein Handy aus den 1990er-Jahren gegeben. Aber dieses alte Handy hat nur sehr wenig Speicherplatz. Tom hat versucht, die Telefonnummer all seiner Freunde einzugeben, aber der Speicherplatz dieses alten Handys reicht nicht aus. Tom hat so viele Freunde, dass es sich nicht alle Namen merken kann.
Tom lost his new cell phone, so his father gave him a cell phone from the 1990s as a replacement. But this old cell phone has very little storage space. Tom tried to enter the phone numbers of all his friends, but the storage space of this old cell phone is not enough. Tom has so many friends that it can't remember all their names.
This example is about the ability of an electronic device to remember personal data. The pronoun refers to the neuter noun "Handy" in this example, so the pronoun must also be neuter ("es").
Option 3: The pronoun refers to a noun that does not exist in the text, but only in the minds of the conversation partners, which is also part of the context.
A dialog:
Walter shows Bernhard an old photo. In the photo, Walter is holding a glass of wine and is sitting with a very old white-haired woman. On the table is a birthday cake with the number 90 written on it in icing. Sitting next to them is a second man who looks a lot like Walter. Walter points to the second man and says,
Das ist mein Bruder, er heißt Tom.
This is my brother, his name is Tom.
Then he points to the woman in the photo and says,
Leider wird ihre Demenz immer schlimmer, und Tom ärgert sich manchmal sehr darüber, dass sie die Namen seiner Freunde vergisst. Tom hat so viele Freunde, dass sie sich nicht alle Namen merken kann.
Unfortunately, her dementia is getting worse and worse, and Tom is sometimes very annoyed that she forgets the names of his friends. Tom has so many friends that she can't remember all their names.
In this example, the point is that the old woman, who is presumably Walter and Tom's mother, forgets the names of her son's friends. Therefore, the pronoun in this example refers to the feminine noun "Mutter" or to the old woman's name which must be a feminine noun, because the named person is female. But in all the words that Walter speaks, there is no mention of the woman's name, nor of the noun "Mutter" or any other noun that could refer to this woman. In the entire example, there is no other feminine noun to which the pronoun could refer. The pronoun "sie" therefore refers to a noun that does not appear anywhere in the spoken text, but only in the minds of Walter and Bernhard. But that is enough. The pronoun must also agree in this case with the grammatical gender of this virtual noun.
The pronoun es is never used like the English they for persons with unknown gender. German pronouns to NOT match with the biological gender of a person!. German pronouns match with the grammatical gender of a noun! This noun can identify a person (like a name or like words like "Mutter", "Lehrer", "Nachbar", ...) but it can also by any other noun ("Handy", "Tisch", "Neugier", ...). So, in German personal pronouns do NOT refer to persons! They refer to nouns!
In German you can (and must) use the pronoun "es" only if the noun that identifies a person is a neuter noun, independent of the persons biological gender:
- unknown biological gender
Das Kind hat den ganzen Tag gespielt, jetzt ist es müde.
Das Baby schläft. Es wird bald wieder aufwachen.
- neuter noun and pronoun for a female person
Das Mädchen trinkt Milch. Es hat langes, blondes Haar.
Das Weib hat mich betrogen. Ich will es nicht mehr sehen.
- neuter noun and pronoun for a male person (Albert Einstein)
Das Genie ist leider schon tot. Es hat die spezielle und die allgemeine Relativitätstheorie formuliert.
If a person's biological sex is known, there has been an exception for about 50 years: in this case, it is permitted for the pronoun to also match the biological sexus. But the matching with the grammatical gender is always correct too.
If you want to refer to a single person with unknown gender in German, you use er/sie in a written text and er oder sie when you speak:
Die Person trug einen schwarzen Mantel mit Kapuze und rannte aus dem Geschäft. Er/sie war ungefähr 170 bis 180 cm groß und steig in ein wartendes Auto, das dann mit hoher Geschwindigkeit davon fuhr.
The person was wearing a black coat with a hood and ran out of the store. They was about 170 to 180 cm tall and got into a waiting car, which then drove away at high speed.