If in doubt, check its source code. 7-zip is an opensource software audited by thousands of developer, to assure its quality, and to prevent any malware or virus. Every change to its source code must be approved, from its version control system. There have been virus in some open-source software, it has happened few time, but most of the time, its because of the version control system was compromised, not because the software is bad. The same already happened with closed source software from big company. If the version control system is compromised, or the server that host the file is compromised, the the hacker can put whatever file he want instead of the real software (server compromised case) or alter the source code ( version control system compromised case).
This is also why many opensource software (and some closed source software) also give you a checksum, so you can verify if the file was also altered during the download, either corrupt, or man in the middle attack.