Getting a second mortgage with a CCJ is possible, but much depends on the specifics of the CCJ.
For instance, a small CCJ (under £100) that is older than three years might have less impact on your application than a larger, more recent CCJ. The lender will consider the amount and the age of the CCJ in their decision-making process.