The rules for a wizard are that they can prepare spells that are in their spellbook, and cast ritual spells from their spellbook without preparing them. There is also the cost and time spent to copy a spell into your own spellbook.
But can one wizard add a spell into another wizard's spellbook?
In theory, it fulfils the rule of being in the book owning wizard's spellbook, but it doesn't fulfil the flavour of the wizard having to decipher and practice the spell for themselves.
Best Answer
Following the rules as they are written, this doesn't work because Wizards have unique notation systems
To quote the Wizard class (PHB page 115):
Because of this even if another Wizard wrote a spell into your spellbook, it would be written in their notation and thus you could not actually use it. This is because:
You cannot memorize the incantations and gestures of a writing system you can't read, so you cannot prepare a spell written into your spellbook by another Wizard.
A GM can rule however they think best fits the narrative
Of course, this all only works under some very strict readings of the rules. A GM is certainly allowed to rule otherwise, especially if the narrative of the story makes sense here. If Wizard A knows the notation system Wizard B uses and writes a spell into B's spellbook (which would still have the time and gp costs), I see no reason B couldn't prepare those spells. After all, to an outsider, the spells written by A and the spells written by B are completely indistinguishable.