I’m not giving you a working solution but just a hint: The JPEG format consists of different parts, some are required and some are optional. Among those optional parts, some allow to store arbitrary data.
If you manage to alter such a part of an existing JPEG image or to add one and put your PHP code to it, you have an JPEG image with embedded PHP code that should be recognized as a proper JPEG image. Then all you have to do is to get that code invoked.
solved How to change file mime type to bypass php shell upload? [closed]