This topic was brought up within the past couple of weeks. I’m certainly not the guy to give you definitive info on a swap like this. That said, I can’t in my mind think that doing this is from financial and time invested standpoints makes sense. I believe you will also need the 10 speed trans to go along with the Gen 2 3.5’s, don’t quote me on this. It no doubt can be done but it isn’t a drop in tighten a few bolts, plug in a few connectors replacement.
Now if you happened to have a low mile 2017 that had been slammed so badly in the rear that it couldn’t be repaired sitting next to your truck, it might be a different story. This also assumes that you’re 2012 is in such stellar condition that it would justify this replant. If what you have is a low mile engine sitting pretty all by itself going into a well used, read tired 2012, well... not so much.
If you’ve got the time, tools and knowledge and are willing to hunt all of the often overlooked pieces, such as the hoses, front drive accessories, mounts etc. to actually do this I’d love to follow your progress. I mean that in all sincerity.