Ship shape does not affect its hyperdrive class at all, no. Hyperdrive class only describes how fast the ship can go through hyperspace, with a lower rating equating to faster speeds. Its size, however, does limit whether or not it can have a hyperdrive and how fast it can go based on hyperdrive size and power requirements.
For example, the Jedi starfighters used during the Clone Wars era, specifically the Delta-7/7B and the Eta-2 starfighters in Attack of the Clones and Revenge of the Sith respectively, were far too small to be equipped with a hyperdrive. The Eta-2's cockpit is barely large enough to accommodate its pilot and its ion sublight drive is likewise quite compact. In both of these small starfighters, an external hyperdrive booster, or ring, had to be used.
An X-wing or Y-wing, on the other hand, has a hyperdrive installed. These are both quite larger than either of the two Jedi starfighters and since they have higher power outputs and larger fuel resources, their spaceframes can accommodate a hyperdrive easily.
A midway point in terms of starfighter development, the Z-95 Headhunter, could be retrofitted with a hyperdrive, but it also ran into another problem that hyperdrive-capable ships had: Navigational systems. The Z-95 could only store a single pre-computed set of destination coordinates (plus their hyperdrive vector) in its navigation system and, as these coordinates require specific and intense mathematical calculations, it would be nearly impossible for a pilot to calculate a new set themselves. The X-wing and Y-wing, by dint of having an onboard astromech droid that specialized in calculating and storing multiple sets of hyperspace coordinates, did not have this issue. Ditto for larger ships with better onboard navigation computers.
Now, when it comes to larger ships like the Millennium Falcon, hyperdrive size is much less of an issue. The Falcon itself boasted an exceptionally fast hyperdrive, because it had been fitted by Lando Calrissian who used a hyperdrive engine that was twice the size of the stock drive fitted to the YT-1300 series freighters yet gave vastly improved speed. But the Falcon is a relatively small ship and hardly stock configuration; other vessels of comparable size fitted with hyperdrives might be faster or slower depending solely on the unit installed.
The Death Star, on the other hand, had what was a fairly slow hyperdrive in part as a result of its sheer size. According to the Legends continuity, the Death Star actually used 123 individual hyperdrive units slaved together to transport the station through hyperspace. It's possible there was some inherent risk of making the Death Star go any faster through hyperspace, or that even with its massive power generation reactor, such speeds wouldn't be attainable due to however physics works (or doesn't work) in Star Wars hyperspace, so the bank of Class Four hyperdrives was the best the Empire could do at the time for a vessel so immense.