It is probably a decent approximation to model the magnetic field as a magnetic field from a dipole. To get the magnetic field from a dipole, you just needed to scroll down a little bit (you can ignore the second term with the $\delta$).
In this case, $\mathbf{m}$ will point along the long axis of the bar magnet. HoweverIf we take $\mathbf{m}$ to point along the $z$-axis, then the expression for the magnetic field becomes $$ \mathbf{B}=\frac{\mu_0 m}{4 \pi r^3} (3z \hat{r}/r - \hat{z}) = \frac{\mu_0 m}{4 \pi r^5} (3z\mathbf{r} - \hat{z}r^2); $$ in components, this is $$ \mathbf{B}=\frac{\mu_0 m}{4 \pi \sqrt{x^2+y^2+z^2}^5} (3zx,3zy,2z^2-x^2-y^2). $$
Now you don'tsay you know the residual flux density $\mathrm{B_r}$. According to wikipedia, this is related to the magnetic moment by the formula $m=\mathrm{B_r} V /\mu_0$, where $V$ is the volume of the magnet. Plugging this into the expression for the magnetic field, we get $$ \mathbf{B}=\frac{\mathrm{B_r} V}{4 \pi \sqrt{x^2+y^2+z^2}^5} \left(3zx,3zy,2z^2-x^2-y^2\right). $$ Now if you didn't know the magnitude of $m$. I think it would be difficult or you wanted to measure precisely. Thedouble check your work, the best way I can think of to do it easily would be to take a gaussmeter and measure the field along the axis of the bar magnet (say 1 cm past the end, 2 cm past the end, etc). This of course requires a tool that can measure a magnetic field.
Fortunately, most smartphones can do this and there are free apps. After reading this question, I searched the app store and downloaded an app called phyphox, and it kind of blew my mind. One of the things it can do is measure X,Y, and Z components of magnetic field. For me, Y was the long axis of the phone, and Z was the normal to the phone. You will have to do some experimenting to figure out where the magnetometer is located in your phone if you go this route. After doing this, you should be able to map out the magnetic field along the long axis of the bar magnet and then fit to your expected form to getsee if it matches the magnitudeprediction of the magnetic moment $m$formula. Then
One caveat is that close to the theory will tellmagnet, higher multipole terms become important, so modeling the magnet as a pure dipole may not give you magnetic field everywherethe best results. You can then double check with your smartphoneHowever, I believe it will be much more difficult to correctly account for the higher multipole terms.