This is what I wrote regarding a similar question about 2(?) years ago.
With all due respect:
I can certainly understand the desire to attempt to paint the engine - in the frame. My answer to this question comes from being reasonably comfortable with working on most any part of the bike, so I am biased here perhaps. My question would be, "What are you looking for as and end result?" I ask because I can not imagine myself taping and masking everything that will need to be, in order to "attempt' to paint an engine, in-frame. Given the amount of time required to mask I would find the whole process easier and a heck of a lot less overall work, to remove the engine. Then you can clean and prep. everything properly from top to bottom and at least have half a chance the paint will stick and have even coverage. I don't see any way of getting the engine clean of oil, oil residue and normal road grime - especially the bottom end - with the engine in-frame. Won't dispute it's been done, but I would question the true quality of the finish and how long those "tough" areas would hold paint. It's a lot of work either way but I'd choose the method that would give the best results with the longest life. And regardless of your painting method - "Rattle-can" most likely - trying to spray an even coat of paint under the trying conditions of being in-frame, will most certainly create a LOT of areas with thin coverage and lots of "runs" trying to cover those areas. It's a question of your expectations. Will it look like it was done right and how long will it last?
Sometimes it's better to leave things as is, do a few touch-ups and just wash and wax the shit out of it. Personally speaking I can appreciate to a far greater extent something that has mileage, wear-n-tear, scratches and chips but is otherwise clean and cared for, over something that has an obvious appearance of being done in a less then complete manner.
I'm obviously strongly opinionated on this topic and it comes from having just removed, cleaned and painted my Oil-pan. It was enough work as it was, having it on the bench! I can not imagine trying to achieve a good paint job "in -frame". And that's speaking of only the pan!
If removing the engine is not an option then consider just touching-up the visible areas of concern. I did some smaller touch-ups on the front of my engine by thoroughly cleaning the areas and painting them by hand with some silver "Rust-oleum" and a fine artists paint brush. The color match is satisfactory and with some care with the brush strokes, the touch-ups are all but invisible.
Half way through an in-frame painting attempt is not the time to regret this decision if your goal is to achieve <...a real good job....>!
So again - I respect the idea and the question but would suggest you really think twice about your options. And good luck either way !
Hopes this helps you make the right decision for your intention and goal.