+1 on cable lube and ensuring no kinks. Do extract the inner cable and inspect for tight spot wear or kinks. See if you can find "speedometer cable lube" at the parts store. There's a good reason for this "specialty lube".
The speedometer needle attaches to a ferrous bell. The cable ties to a sectioned bell that has magnets. As the cable turns, the magnet pulls on the bell which deflects the needle.
If the gauge bearings wear out from old stale lube, the two bells can come in contact and that makes the needle deflect irregularly from friction contact.
Taking apart the speedometer is not for the timid, or neophyte. Easy to mess things up inside and replacement internal parts are not readily available.
But, if you have more prowess than the norm, go for it!
If a refurbished or new cable doesn't correct the needle bounce, getting another gauge is the easiest option.
Cheers,