I had learnt that the dipole moment is defined for 2 point charges only with equal magnitudes but opposite character.
Actually, that is not the case. You can calculate a dipole moment for any charge distribution.
In fact, the dipole moment is just one of a whole series of multipole moments which can be used to describe a charge distribution.
- The monopole moment $$q = \sum_i q_i$$
- The dipole moment $$\vec{p} = \sum_i q_i \vec{r}_i$$
- The quadrupole moment $$\overset{\leftrightarrow}{Q} = \sum_i q_i(3 \vec{r}_i \otimes \vec{r}_i - r_i^2)$$
and so on. These moments are kind of analogous to the coefficients of a Taylor series expansion.
It turns out that if you take a positive point charge and a negative point charge of equal magnitude and bring them infinitesimally close together, then the resulting charge distribution (called a dipole) has only a dipole moment. All the other multipole moments are zero. That's where the dipole moment gets its name. You've been taught that you can calculate a dipole moment for a system of two charges because that is the simplest way to create a charge distribution with a dipole moment. But it is not the only way.