Both particles negate an imperfect in the past, but their meanings are different.
لَمْ يَكْتُبْ زَيْدٌ — Zayd did not write at all. This is emphatic past negation.
لَمَّا يَكْتُبْ زَيْدٌ — Zayd has not written yet. The non-occurrence continues up to now.
Choose the particle from the intended meaning, not merely because both verbs are jussive.