Awk is a command which is an interpreter for a programming language that is aimed at simple text processing. Though it can, it's not really meant to be used to call other commands like the `head` command.
Here, you could have a shell do the work:
find . -type f \( -name '*.jpg' -o -name '*.jpeg' -o -name '*.png' \
-o -name '*.html' \) -exec sh -c '
for file do
IFS= read -r line < "$file" &&
case $line in
("#!"*) printf "%s\n" "$file: $line"
esac
done' sh {} +
If you wanted to do it with `awk`, with GNU `awk`:
find . -type f \( -name '*.jpg' -o -name '*.jpeg' -o -name '*.png' \
-o -name '*.html' \) -exec awk '
/^#!/ {print FILENAME ": " $0}; {nextfile}' {} +
With other `awk`s:
find . -type f \( -name '*.jpg' -o -name '*.jpeg' -o -name '*.png' \
-o -name '*.html' \) -exec awk '
BEGIN {
for (i = 1; i < ARGC; i++)
if ((getline < ARGV[i]) > 0 && /^#!/)
print ARGV[i] ": " $0
exit
}' {} +