Yes, you can place the new sub-panel right next to the existing one assuming you still have the correct clearance/working space. (moved my comment to an answer at isherwood's request). Ed already answered it by now.
Can you install a sub panel next to a main panel. The answer is yes what it is for is not an issue.
However you have a maxed out panel, a maxed out panel doesn’t mean it can’t be done. Tankless water heaters are power hogs and your existing panel probably will not have the ampacity to carry the load even understanding a 30 amp 240v breaker will be removed.