Get availability group and listener of the current DB (dynamic SQL)
You need to run queries agains the DMV to get the AG name. 

Here's some code you could use as a base:

select DB_NAME(AG_DB.database_id) "DB", AG.name  "AG Name", li.dns_name "Listener"
from sys.dm_hadr_database_replica_states AG_DB
join sys.availability_groups AG on AG.group_id = AG_DB.group_id
join sys.availability_group_listeners li on li.group_id = AG.group_id


This will only returns databases that are in AG (vs a query in sys.databases which will return the system DB as well).

P.s. If you do not need the listener (which seems to be the case) then you do not need the 3rd table and it will keep the query pretty simple.