Your Mac also stores the information about Wi-Fi access points it connected to in NVRAM.
From the Apple Support article:
NVRAM (nonvolatile random-access memory) is a small amount of memory that your Mac uses to store certain settings and access them quickly.
While iCloud keychain also stores the Wi-Fi access point information, it's tied to a users Apple ID.
So if you are looking for a scenario where you want to give away your Mac to someone else, and do not want the Mac to retain crucial information such as your Wi-Fi access point password, you could, in addition to wiping the hard drive/reinstalling the operating system also take additional steps to reset NVRAM and PRAM on your Mac.
The linked article describes the steps to reset NVRAM and PRAM.
How to reset NVRAM
Option + Command + P + R
Shut down your Mac, then turn it on and immediately press and hold these four keys together: Option, Command, P, and R. You can release the keys after about 20 seconds, during which your Mac might appear to restart.