It can be done. Every voting machine gets a key. Voting machines send results inside a secure VPN network. Votes itself can be duplicated on paper inside the voting machine. The voting machine might not need to be connected to the internet as you can have a separate terminal operated by a staff member.
We have ATMs working securely for decades. It is a largely solved problem. Problem is that the government is not willing to pay for a secure solution.