How does Ditto's transform work against a raid boss?
When Ditto uses transforms in a battle, the answer provided on this question says
It appears that as far as CP is concerned, Ditto simply takes on the base attack, stamina and defense stats of the Pokémon that it transforms into. These values, along with the Ditto's individual values, are plugged into the CP formula.
The formula and calculations are also provided as well.
This works for regular gym battles against other trainer's Pokémon, however raid bosses have anywhere between 8,000 - 25,000 CP with IVs that are probably higher than anything a gym will hold.
How does Ditto's transform ability work when fighting a raid boss?
Information in this thread indicates that Dittos behave against raid bosses just as they would against regular gym defenders. That is, the Ditto will pick up the Attack and Defense IVs of the raid boss and convert its CP accordingly. However, it will not increase its HP stat or its level, so it will likely just be a sort of glass cannon, depending on what it transformed into. The reason that raid boss Pokémon have such high CP is due to them being buffed to a level impossible to actually attain as a player, which a Ditto wouldn't copy.
Just saw my first raid and went for it even though it was an easy difficulty level. Croconaw, CP5207. Ditto transformed into him and didn't even faint as myself and another trainer's Jolteon defeated it in 27 seconds. My Ditto was CP1270 after using transform, but was surprisingly able to weather two Crunches and a few Scratches. (A 96%, L28.0 Croconaw is CP1270, by the way—same level and IVs as my Ditto, Blob Loblaw. I still feel like there's something else at play, since he was able to survive two Charge moves.)
In other words, Ditto isn't completely useless in raid battles, since it will likely have a high defense against the raid boss (turning into a Venusaur whose Solar Beam is now 4x ineffective against a transformed Ditto, etc, but exact opposite situation if transforming into Dragonite (weak against its own typing)), but since a transformed Ditto retains its HP, it likely won't last too long in battle.