IANAL, as usual and if you are seriously in the business of earning money this way, you should definitely hire a lawyer for this.
The basic idea is that you can do pretty much whatever you want in your license.
Normal proprietary licenses are one things: you may use it, but nothing else.
Open source licenses are the other end of the spectrum: you may use it, modify it, redistribute it (and sometimes some restrictions as well).
You can put your own license anywhere in that spectrum (and probably somewhere outside that spectrum as well). So it would be fine to write a license that says "you may use this, read the code, modify the code, but you must not re-distribute the code (modified or unmodified)".