Yes, you can spend the night on a yacht! Most yachts are designed for extended stays and are equipped with everything you need to enjoy a comfortable overnight stay on the water.
Most yachts come equipped with sleeping quarters, such as cabins or berths, as well as bathroom facilities and a kitchen or galley.