You can store the password in a Hook – this will be encrypted so long as you have setup your fernet key.
Here is how you can create a connection via the UI:

Then:

To access this password:
from airflow.hooks.base_hook import BaseHook # Deprecated in Airflow 2
connection = BaseHook.get_connection("username_connection")
password = connection.password # This is a getter that returns the unencrypted password.
Update since Airflow 2 launch
The library airflow.hooks.base_hook has been deprecated and you must use airflow.hooks.base instead.