After about 10 minutes proceeding directly toward ZZZ, the ceiling lowered to about 1,500 [feet]. In the vicinity of [a wildlife refuge], it lowered further. At first I thought this was a brief “sag” in the clouds and would return to 1,500 [feet]. After about 15 to 20 seconds in IMC and no longer able to see the ground, I executed a climbing standard rate left turn in order to return to VFR on top. I used my Garmin G5 to fly this segment in IMC. Just prior to this, ATC had warned of an obstruction at my 2 o’clock, which I noted on my ForeFlight display as well; hence the left turn. During the ascent, ATC asked if I was IFR rated and wanted an IFR clearance. I responded, “Negative.”
Once VFR on top, I completed a 360 [degree] turn and headed west toward [another airport], which ATC suggested as a VFR airport.… I notified ATC and terminated Flight Following with the airport in sight.