2007 it's a very old model, so it's not excellent exampleIn an older iMac (mid 2007/Aluminum model,) I successfully upgraded the CPU to a newer-generation one that is on the same socket, with the same chipset support. But the OS reports it wrong. It is a Core 2 Duo T9500 2.6 GHz. Running Windows, it reports correctly. Running a low-level CPU detect utility, it detects correctly. But the "About This Mac" window claims it is "700 MHz Intel Core 2 Duo". It obviously works at full speed, though, as it can play 1080p videos just fine (something a 700 MHz CPU wouldn't be able to do.) And Handbrake compresses videos at the same speed in Windows as Mac OS. People have also upgraded various generations of tower Mac Pro to one-generation-newer-same-socket CPUs, including upgrading the original 2006 model to quad-core CPUs.
So, if the chipset has support, and it's the same socket, it should work.
The big thing to note is that current rumors are that Coffee Lake will require new chipsets. So I couldn't count on the current models supporting that particular upgrade.