If you want the file to have a genuine file extension of a picture file format like *.jpg then you will need to identify a vulnerability in a graphic software that you can exploit for arbitrary code execution and weaponize to get your image ran from memory by the affected process (which in this case would be Microsoft Paint, Microsoft Photos UWP application, etc.).
However, you would be assuming that the user of the system will be using the same software you have exploited to open the image up.
If you already have code execution on the target machine then you can use any extension you want on the file and then have it executed as long as it is identified as executable by the PE file header markers (e.g. MZ bytes at the start of the binary) or a manual loader for it.
Your best bet would be exploiting the human mind: make the file appear to be an image and open up a genuine image on execution, but really it would be executable in some shape or form. There are many tricks that can be played with archive formats and Java as well.
However, you would be assuming that the user of the system will be using the same software you have exploited to open the image up.
If you already have code execution on the target machine then you can use any extension you want on the file and then have it executed as long as it is identified as executable by the PE file header markers (e.g. MZ bytes at the start of the binary) or a manual loader for it.
Your best bet would be exploiting the human mind: make the file appear to be an image and open up a genuine image on execution, but really it would be executable in some shape or form. There are many tricks that can be played with archive formats and Java as well.

