First I would check the connections between the sender and the gauge to make sure they are clean and solid. Typically there is a connection at the back of the engine where the sender wires connect to the boat wiring, and the connection at the back of the gauge. If those are good I would disconnect the sender wiring in the engine bay and monitor the resistance of the sender while you raise and lower the drive. If the reading is erratic, it's the sender. If the reading is smooth and tracks well with the drive position, it could be the gauge. You should be able to Google the expected resistance range of the sender.