Yes, that’s the idea, although you want to do it when Earth is just a bright dot in the background. You actually could do it with simple mass, too, but (unless we are lucky with the trajectories to begin with), it takes a lot of energy to accelerate that mass to a velocity that gives it enough kinetic energy to do the job. Right now, our best way to deliver a lot of energy to an incoming object ~ 2 weeks away is with a nuke.
BTW, what’s the original date of that top image?