This idea has been nagging me for some time, so I'm gonna share it here to spark some comments, ideas, or flames. Maybe this has been done before too ?
A species a bit more advanced than the Federation could have invented a shapeshifting ship. In fact, the ship would consist in a very advanced replicator, along with a powerful generator and computer, and a vast amount of "replicator matter" (I don't remember the correct technobabble name).
Thanks to the data stored into the computer, the replicator would then be able to replicate a whole ship around it with the matter, down to the interiors if needed, with all the according equipment (transporter, phasers, consoles... down to the decorations in the crew quarters if the computer has the data or the programmation to do so). With this ship, it'd then be possible to replicate the appearance and performance of virtually every existing ship in a minimal amount of time (something like a few minutes or less - after all, replicators are very fast), save for the smallest ones (runabouts), or the biggest ones (Borg Cube). The replicator could also nearly instantly repair the ship when damaged.
The ship could also come equipped with a advanced sensor that'd allow it to scan other ships in order to reproduce them.
Now I don't really know how this ship could be used - for one thing, it could be the ship equivalent of a Founder, used for infiltration or various similar schemes. Or this technology could belong to a new hostile race - in wich case, they'd be more dangerous than the Borg (let a Sovereign be captured and next time there's an army of them waiting for you). Of course, speaking of Borg, we don't really want this technology to be assimilated...