had a stray dog not have given them away.

what's the grammatical name n function of the sentence?

In the first place, it's a clause, not a sentence.

Also, it is not even syntactically correct.

A valid clause might be

had a stray dog not given them away, ...

a use of the subjunctive, equivalent to

if a stray dog had not given them away, ...

It is an adverbial clause

Adverbial clause

Adverbial clause

What sorts function

Adverbial clause

Adverbial clause of time

Adverbial Clause

Adjectival clause

Adverbial clause