If the camera works fine otherwise, ie normal distance shots, it might be you are too close or the camera just can’t lock the focus. It might be better with a different camera app that allows manual focus, if you search the App Store you should find a few, one of the free ones is Lightroom CC that I use along with Halide (not free), both allow manual focus along with adjustment for other settings.
ps. The additional benefit of using a third party camera app is that it will test the phones hardware, in other words if the third party app works ok then it could point to the original camera app software being the issue, just a thought.