Not going to work. It's a known issue: ever since they changed the dragon fight sequence these mobs are no longer useful in custom worlds unless you play around x0, z0. And even then it's mediocre at best because they'll always include the "hover over portal" and "die above portal" sequences even though there isn't a portal in the Overworld to begin with.
You can experiment with other dragon phases but that only gets you so far: after the dragon finishes his routine it'll immediately fly off again.
Theoretically you could set up a bunch of command blocks (with timers) which all instruct the dragon to run through a specific phase. If you time it right you might be able to string the whole thing together in order to prevent the dragon from performing phases 2 (fly to the portal), 3 (land on portal) and 4 (take off from portal). But even that only gets you so far because the dragon death sequence basically starts with phase 9: flying to the portal to die there.
So unfortunately I don't see this working on modern Minecraft versions.