Yes, you can. The cost and complexity will depend very much on the kind of heater you choose; for example, an electric heat pump model is relatively simple to connect but produces a lot of condensation, so you must consider drainage. A natural gas heater must be situated away from windows and doors because of the risk of fumes, and it will require a connection to a gas supply or tank. And solar swimming pool heaters will need room for the solar panels or a connection to existing ones.