I've heard 6DOFJoint could be used like that, but the documentation isn't great and I never got it working. Depending on what you are doing, you can also use a PinJoint. If you adjust the parameters it can kind of act like a spring, but it depends on your use case.