Is "will never have been" valid English?
As user FumbleFingers pointed out, "will never have been" is standard English: you can find it in many books over the centuries.
Roughly, it indicates talking about the past at some future time. More precisely, "there will never have been X" means that at some future time, it will be true that "there has never been X". For instance,
The new weapons have not been tested, but it is planned to test them starting next August. If they are used later than that, they will have been tested before use. If war breaks out before that, they will never have been tested.
Or, to attempt self-reference :-),
Children entering school this year will leave in 2023. By the time they leave, most of them will never have been exposed to the phrase "will never have been".
The context you quoted:
I will give you a wise and discerning heart, so that there will never have been anyone like you.
can be interpreted as:
Right now, since you (Solomon) have an ordinary heart, there have been others like you, and there are others like you.
After I give you the new heart, you will be unique: people will be able to say "there has never been anyone like Solomon". At that moment, there will never have been anyone like you.
Yes, it’s grammatical. It’s the future perfect tense, formed:
will (not ) have + past participle (e.g., been, gone, had )
Which describes a future action that will occur before some specified point in the future. In your example, never is merely a qualifier that both negates (not) and adds emphasis (ever).