Yes, this is possible. The most natural option is to look at identity-based encryption (I point to the wikipedia page, as it gather some links to various schemes), such as the Boneh-Franklin IBE. An IBE allows to encrypt a message with the identity of the user. After interacting with some trusted authority once in a setup phase, each user can receive the secret key associated to this identity, and decrypt all messages encrypted for their identity. The owner of the master secret key (which is used to derive identity-based secret keys) can decrypt all messages, for any identity. Your intuition about looking into attribute-based encryption is essentially correct, as IBE is a special case of attribute-based encryption.
In fact, you do not need the full power of IBE here, so there is an alternative possibility. The exact feature that you are looking for is enjoyed by the Bresson-Catalano-Pointcheval cryptosystem. Close variants of this scheme were invented simultaneously the same year, by Damgа̊rd and Jurik, and by Cramer and Shoup. It allows to perform the following operation:
- Generate a pair (master public key, master secret key) $= (\mathsf{mpk},\mathsf{msk})$
- Given the master public key $\mathsf{mpk}$, any user $P_i$ can generate a pair public key / secret key $(\mathsf{pk}_i,\mathsf{sk}_i)$
- A message encrypted with $\mathsf{pk}_i$ can be decrypted either with the corresponding secret key $\mathsf{sk}_i$, or with the master secret key $\mathsf{msk}$.
Note that unlike IBE, you cannot simply encrypt using the identity of a user in this system. However, generating a pair $(\mathsf{pk}_i,\mathsf{sk}_i)$ can be done by any user, using only the master public key (while in IBE, the mastersecret key is needed to derive the secret key associated to an identity), so you do not need to have a trusted authority at this step. This might make this scheme more suited than IBE for your exact application.
If you are familiar with the Paillier cryptosystem and the ElGamal cryptosystem (otherwise, ignore what follows), the idea of the scheme is quite natural: a ciphertext is of the form $(g^r \bmod n^2,(1+n)^mh^r \bmod n^2)$, where $n$ is a product of two safe prime, and $(g,h)$ is some specific public key. Given the factorization of $n$, one can decrypt this ciphertext exactly as a Paillier ciphertext, by ignoring the first part of the ciphertext (the second part is exactly a Paillier ciphertext). Alternatively, given $s$ such that $h = g^s$, the ciphertext can be decrypted with a standard ElGamal decryption.