You'd need to avoid the inter-ethnic bloodbaths of the Axis occupation, and the communist takeover. And both are consequences of the well-intentioned but misguided coup of 1941. Prince Paul's/Cvetkovic-Macek regime would need to enact its 1939-41 policies in a smarter way, in order to preserve more popularity and discourage the plotters.
First, to reduce Croatian separatism and general discontent, it needs to federalize (as per OTL's 1939 agreement); and to enshrine the new order in a new constitution, so people know it's not just a temporary arrangement. Then, to avoid alienating the Serbian population, it needs to crack down on abuses of minorities in autonomous Croatia and complete the federalization.
Temporarily joining the Axis is another necessity, however unpopular it might be. Yugoslavia should play hard to get until it secures OTL's terms - that the Axis can't demand military assistance or right of passage from Yugoslavia. It'd be smart to keep secretly cooperating with France and Great Britain, but only with great care, so the Nazis don't discover it like they did in OTL. Then, when the opportunity arises, switch sides and join the Allies. This probably allows Yugoslavia to stay a monarchy and firmly on the western side of any iron curtains.
Of course, Yugoslavia might fall apart later anyway, but it's a lot less likely.