Well what I think is most probably it would transform into one of the pokemons that ditto can target . For eg. If ditto is on the right . It cant attack the pokemon on the left and can attack only the pokemon in the centre and right so probably transform into one of those.
Again im not sure because I havent tried this yet but I hope this is quite what it is.