In the Rebels series, the hyperspace-capable creatures known as the purrgil were known to grab smaller starships and drag them through hyperspace with them. That might not be the best example for you, though, since it's a creature and not a mechanical starship.
The Carrack-class cruiser is a light cruiser used by the Empire. It was too small to have a hangar bay, but could carry a handful of TIE Fighters attached to external racks. That's the same general concept of a smaller vessel attaching itself to a larger vessel and hitching a ride through hyperspace.
A Carrack cruiser's racks are specifically designed for this, though. Whether this would work for the Falcon would most likely come down to how strongly it can hold onto the Star Destroyer. Han mentioned they were attached via a "docking clamp". That implies that it's strong enough to keep the two ships from drifting apart while stationary. I can't find any specifics, but I'd find it unlikely that it would be strong enough to hold on for a hyperspace jump. Even rapid maneuvering with the sublight engines could likely "sling" the Falcon off of the hull. Those are forces far beyond what a "docking clamp" would reasonably be expected to handle, so it's unlikely that such a system would be overengineered to that degree. You'd still want to detach before the Star Destroyer made the jump, though. Who knows what kind of damage that would do to your ship.