Welcome to the forum.
I'm not an expert on this, so I may get this wrong as well, but at least we'll be wrong together.
Let's take a look at what you did write:
あなたはかいてる、それは早朝でした。
You are writing, that was early morning.
Good try, but confusing. The first point I will make is you want to avoid "you." Unlike in English, using pronouns is considered to be rude. If you know the person's name, use it, or even better just omit it entirely. Japanese is very contextual, so you don't need to constantly say "you," "me," "Joe," "Barbara," etc. This stuff can be understood through context.
Now, how do we say "When you wrote me, it was early in the morning?"
First way is similar to how you were doing it above: don't say "when." "You wrote me early in the morning."
早朝に私を書きました。
I'm going to give you a caveat: かく, "to write," may not be the correct verb for this. There is one for "to write to," かきおくる. Though looking at Google it doesn't seem very common, but I'm a little cautious in using Japanese verbs exactly as we do their English equivalents; they might not be as flexible in the same ways. That said, I'm going to act like かく is correct, because I do not actually know it's not.
With "when," there are at least three different ways to do it. The most straight forward, because it is the closest to mirroring English, is probably to use とき, or "The time you wrote me was early in the morning."
私を書いたときには早朝でした。
You can also use たら--conjugating the verb into the plain past form + ら--which is a bit weird because たら is a conditional, so it's kinda like saying "if you wrote me," but it's really not in this case. You use this if you are surprised that your friend wrote you early in the morning. If you expected him to, don't use this.
私を書いたら早朝でした。
Finally, there's と, which picks up the tense only from the last verb, so the first one is written in the plain present.
私をかくと早朝でした。
Hopefully this helps and it's not too far off from the truth