Yes, you can do it programmatically and it probably can be built with some of the Related Questions listed here on the right of the page.
But, IMO, this is faster and easier to do with a plugin.
Advanced Custom Fields
Create an image field and associate it with your Custom Post Type.
That results in:
Another good plugin capable of doing the same
Custom Content Type Manager
A nice feature is the “Repeatable Field”, which is a premium add-on in ACF.
Reference Q&A: Creating Photo Gallery System with Custom Post Type