You may refer the virus/malware type called 'Polymorphic Virus'.
A polymorphic virus is a complicated computer virus that affects data types and functions. It is a self-encrypted virus designed to avoid detection by a scanner. Upon infection, the polymorphic virus duplicates itself by creating usable, albeit slightly modified, copies of itself.
Source: https://www.techopedia.com/definition/4055/polymorphic-virus
Trend Micro explains it this way:
Polymorphic viruses are complex file infectors that can create modified versions of itself to avoid detection yet retain the same basic routines after every infection. To vary their physical file makeup during each infection, polymorphic viruses encrypt their codes and use different encryption keys every time.
Source: https://www.trendmicro.com/vinfo/us/security/definition/Polymorphic-virus
You can find some example of such codes here:
http://www.informit.com/articles/article.aspx?p=366890&seqNum=5