A stronger Republican campaign could've won outright in 2012, even with the "blue wall" staying blue. The states Romney won plus Florida, Ohio, Virginia, and Colorado gives you a slight electoral victory. All of those states went pretty narrowly for Obama in 2012, with Colorado giving him the largest margin (5.36%). What's more, the "blue wall" itself was never as solidly blue as it was claimed to be. A strong GOP campaign could've flipped a couple of the states that "surprisingly" (for some) flipped red in 2016.
With that in mind, the scenario in the title is definitely doable IMO. Romney gets a plurality of the vote, winning all the states that he won IOTL plus Florida, Ohio, and Virginia. Obama wins the electoral vote 272-266. Lots of drama ensues, with many Republicans demanding recounts in Pennsylvania, Iowa, and New Hampshire.
As for how to make that result happen, I think you have to have Obama screw something up. Preventing the leak of the 47% tape would help, but aside from that, Romney is just...well, Romney.