This can be done if the spell is on the wizard spell list - and I scribe a spell scroll for the spell first.
It's important to note that this question is about transcribing spells into a wizard's spellbook from other sources, not about preparing spells.
According to the "Your Spellbook" sidebar in the wizard class description:
Copying a Spell into the Book. When you find a wizard spell of
1st level or higher, you can add it to your spellbook if it is of a
spell level you can prepare and if you can spare the time to decipher
and copy it.
This means that as long as a spell is on the wizard spell list and is in written form (spells don't just randomly float around after all!), it can be added to your wizard spellbook regardless of the class of the person that actually wrote the spell down. Typically, this transcription is done from some other wizard's spellbook - but not always.
Xanathar's Guide to Everything, one of several official collections of optional rules, (p. 133) lists Scribing a Spell Scroll as a downtime activity:
With time and patience, a spellcaster can transfer a spell to a
scroll, creating a spell scroll.
There's a short list of what's required to create said scroll, but assuming those are met, any spellcaster using these optional rules can do it. Note that the text does not require the caster have the Spellcasting feature, merely the ability to cast a spell.
So, if any spellcaster can create a spell scroll, and if a wizard can add any spell they find to their spellbook as long as it's on the wizard spell list, the only remaining question is whether or not a warlock has access to spells on the wizard spell list. And as it turns out, most of the spells on the warlock spell list are also on the wizard spell list.
TL;DR: Assuming that the campaign is using the optional rules referenced above from Xanathar's Guide to Everything and that the warlock spell I want to add to my spellbook is also on the wizard spell list, all I have to do is scribe it onto a spell scroll and I can then transcribe it into my spellbook.