If you hear a clicking sound when you shake your phone, it's probably related to the camera's image stabilization function and isn't problematic.
The main camera on the back of your phone provides optical image stabilization (OIS), which reduces photo blur and provides smoother videos:
To verify the sound is from the camera:


Gently shake your phone.
If the sound is barely perceptible, then it was related to the camera's OIS and nothing is wrong with your phone.