My wizard is in a pinch and needs to learn a spell the party warlock knows.
Can he teach me? Assume the spell belongs to both classes lists.
If it makes any difference, you can assume he has pact of the tome.
From a lore perspective, definitely not. To begin, Wizards and Warlocks use different methods of producing magical effects. Wizards study for years to understand how the Weave works. They experiment with and manipulate arcane powers to develop spells.
"They learn new spells as they experiment and grow in experience" PHB 112
Warlocks, on the other hand, channel the power of their otherworldly patrons and do not understand the inner workings of that magic themselves.
"The magic bestowed on a warlock ranges from minor but lasting alterations to the warlock's being... to access to powerful spells." PHB 105
"Various patrons give their warlocks access to different powers and invocations..." PHB 108
What this means is that your warlock doesn't know enough about the spell to actually teach your wizard how to cast it. This would be like asking for directions to bake a cake but only being told to heat eggs, flour, and milk in the oven.
From a technical perspective, also no. Wizards can learn new spells from various sources, including other people. However, the PHB is very specific about those people also being wizards:
"Copying that spell into your spellbook involves reproducing the basic form of the spell, then deciphering the unique system of notation used by the wizard who wrote it. PHB 114 (emphasis added by me).
"They can also learn them from other wizards, from ancient tomes or inscriptions, and from ancient creatures... that are steeped in magic." PHB 112 (emphasis added by me).
Now, nowhere in the PHB is it explicitly stated that a wizard cannot learn spells from a warlock, but it is very heavily implied.
On a side note and as a friendly reminder, do keep in mind the purpose of RPGs. You're coming together as a group to create a story. The official rules are guidelines for that story, but the players and the DM are the ones writing it. If you think that learning a spell from the warlock would make the story better by providing deeper interaction and character development between your character and the warlock or enhancing the current plot, then consult your DM about that between sessions.
The rules for copying spells into spellbooks appear on PHB 114.
When you find a wizard spell of 1st level or higher, you can add it to your spellbook if it is of a level for which you have spell slots and if you can spare the time to decipher and copy it.
Since the Warlock generally doesn't rely on written spells, you're usually out of luck.
There are a few possible workarounds, within some limitations.
There's a limited in-class exception, provided the Warlock built with teaching Wizards in mind. If the Warlock took Pact of the Tome boon AND the Book of Ancient Secrets invocation AND had a non-cantrip Wizard ritual in there, then it would be a valid source for the Wizard to copy from. Bonus: The wizard could reciprocate by providing his ritual spells to the Warlock.
The only really reliable option you have is to let the Warlock guide you in taking a level of Warlock yourself. If you need a spell of higher than first level, this will be a real slog.
If the Warlock happened to take the Ritual Caster feat, and scribed a known spell (of level 1+) into it, that was also on the Wizard spell list, it would be a valid source to copy into the Wizard's spell book.
Depending on how your DM rules crafting magic items works, it may be possible for the Warlock to craft a scroll containing a Wizard spell, from which the Wizard could learn the spell.
If your DM is generous, you can use the Research downtime activity to research a spell. If the DM allows it, there's a good argument to be made that having someone who knows the spell is a great resource for figuring out how it works. There's very little guidance on this in the DMG, and it mostly boils down to a DM judgement call.
One way this could be accomplished is by using the Magic Item Creation rules (DMG 129) during downtime to have the Warlock create a spell scroll. The DMG implies that anyone who can cast spells can create a scroll in their downtime. As we know, once a scroll has been created, it can be used to transcribe the spell into any Wizard's spell book, as long as the spell is on the Wizard's spell list.
Since it is listed as a down time activity, this process can be prohibitively long to slap into the middle of a campaign, since it would count as "Creating a Magic Item". For characters with a ritual book (as a Pact of the Tome Warlock for example), a Wizard would be able to copy from that book just as they would from a Wizard's spell book as long as they have the spell on their own spell list.
The "Your Spellbook" sidebar (PHB 114) says that Wizards can copy spells into their books from sources other than scrolls (as in, consumable items used to cast spells instead of memorizing them and using a spell slot), such as from your own, or another Wizard's spell book. Unlike when using a scroll, scribing from arcane notes of others allows a Wizard to copy the spell, whereas the scroll is consumed. A more detailed explanation of the difference between a Spell Scroll, and a spell that happens to be written on a scroll can be found here.
Assuming that a Warlock is familiar with the use of such arcane notes, such as those with the Pact of the Tome feature, this could be a much faster and cheaper way to reproduce the same results as creating a Spell Scroll for the purpose of sharing a spell to a Wizard's Spell Book. Since the Pact of the Tome feature essentially pulls this ability from the Wizard class, it seems only natural that spells could easily be shared this way as if the Warlock's Tome or Book of Shadows were essentially the equivalent of Wizard's Spell Book.
As a Wizard is a student of the arcane, I see no problem having them study the way a Warlock friend casts spells in order to expand their repertoire of spells, as long as the spells appear on both spell lists. In essence this would be spell research (which there are rules for in the downtime activities). Since the Warlock could be acting as a tutor, this could provide the DM with a reason to expedite the normal spell research process without breaking verisimilitude if they wanted. I have done similar things many times in my games by using one or more appropriate skill check, Intelligence(Arcana) in this case.
Many DMs make the mistake of viewing situations like this from a position of it being impossible until proven otherwise. Remember that this is a game. If one of my players is legitimately underpowered due to a lack of spell availability, and there is a good way for their character to bond with another player's Warlock character, well, that is a heck of a lot better for the group dynamic than if they found the same spell as a scroll in the dungeon. I would still make them roll for it to make it feel earned, but I really don't see any reason not to allow this.
From a RAW perspective, I don't read the sources a Wizard can draw from to add spells to their book as prohibitive, but rather as a springboard for the imagination, the budding beginning of a list of potential possibilities.
From a balance perspective, I don't think that a Wizard having a few more spells in their book would change their power level all that much, especially since Divine casters have access to their whole spell lists and either way they still can only memorize a certain number in a given day regardless of how many they have in their book. There are exceptions for rituals and things, but Divine casters have automatic access to all of their rituals, so I doubt that a few additional spells being taught by the party's Warlock would upset the balance of the game.
From a game perspective, it is the responsibility of a good DM to foster a fun environment, it is a game after all, so they should be willing to consider ideas like this instead of automatically starting with "no" answers.
All that being said, if your DM decides to play hardball on this, don't let it ruin your fun. Express your opinion, make your case, accept their final verdict and move on to the next part of the adventure, maybe they have a surprise up their sleeve that will make your Wizard more relevant to the game that will be better than a few extra spells.
Anyone with the ability to cast a spell can craft a spell scroll of any spell they know if the DM chooses to allow magic item creation. Spell scrolls, once created, are not tied to any particular class. A wizard can attempt to add any (level 1+) wizard spell to their spell book from a scroll.
This can be easily done for low level spells, while high level spell scrolls can take quite a long time and expense to craft.