I had the exact same issue with my 2018 Elantra GT hatchback. I ended up fixing mine. The issue can be (as long as the wires, and mechanical latch mechanism are in good condition and undamaged) the contact switch (this is what the hood sensor is) inside the hood latch. Its a contact switch worth about $2 at most. What I did is force down the hood latch in the closed position and then gently (and carefully!!) with a very thin flat screwdriver lifted up the flat metal piece (without breaking it) that contacts the switch in a better position. Afterward I just closed my hood and checked if the it sensed that the hood was in the closed position. Afterward I opened it up to see if it the switch still functioned properly and showed when it was open. Saved my self $400 at the mechanic.