This scenario would make a good pre-election movie.
Already done, though instead of hacking, there was an apparently untrivial bug in the algorithm - Man of the Year (2006), with Robin Williams and Laura Linney.
It "works" much better in the movies - like James Bond or Mission Impossible series - than in real life. In real life it's a lot easier to "find" mailbags with stuffed mail-in ballots floating in the river or the dumpster, or miscount "chads" than it would be to hack an electronic ballot machine (especially if there is a verifiable paper output).
Nobody complains about optical-scan inked ballots, yet in the academic environment it's fairly easy to hack / reprogram the computer that scans and counts these.
Any electronic device can be hacked given enough time and resources, but that doesn't mean that they are not an improvement on existing systems (paper, stones, papyrus, inked fingers, etc...) The proper security environment in each would be essential to prevent cheating and "hacking".