If the 052D can fit a YJ-18 why wouldn’t it be able to fit a YJ-12?
I think it has to do with the side intakes. To provide enough clearance, the side intakes are aligned to the four corners of the square canister. But wait, the U-VLS does not use square canisters and requires cylindrical canisters. The canisters have to be cylindrical to allow the exhaust gases to transfer out between the gap of the inner canister wall and the VLS wall. No surprise that supersonic ramjet missiles that are VLS launched, such as Oniks, have nose mounted annular intake, while every supersonic missiles with side intakes have to be slant launched. Of course, the recessed intake of the YJ-18 doesn't have that issue.
The other thing is, that ramjet engines may not be as efficient from a vertical position than a slanted position. From a slanted position, the missile can use more of its energy to go forward and reach its ignition speed faster.
From a vertical position, the YJ-12 missile may need a new booster over the one used for its slant position.
Finally we have to come to the real question --- what for? The YJ-18 has made the YJ-12 redundant on the ship. There is also the question or debate which of the two is more effective, with factors such as flight height, range, terminal velocity and evasion.
The last question is why the YJ-12 is still used on ships? You can see its the smaller of the two missiles. YJ-12's size makes it convenient to be carried around by truck, or flown on an H-6. Its size also makes it a convenient replacement for ships that already used the YJ-83. The length of the YJ-18 makes it difficult for those applications.