That's not the here string, it's ANSI-C quoting:
Words of the form $'string' are treated specially. ... The expanded result is single-quoted, as if the dollar sign had not been present.
So what you've got is a single-quoted string to the right of
<<<. That string gets taken as the here string, with no further processing.
There's no need to use only a single set of quotes around the whole word, however. You can use several quoted parts (or unquoted single words) joined together:
script <<< "$var 2"$'\n'"3 4"$'\n'"5 6"$'\n'q
will do what you wanted.
Alternatively, you could backslash-escape the spaces, rather than quoting
You could also use
echo -e with a regular pipe:
echo -e "$var 2\n3 4\n5 6\nq" | script
printf '%s 2\n3 4\nq' "$var" | script
-e is necessary to enable escape processing in
printf does those by default, but it has its own interpolation system (
printf "$var 2\n3 4\nq" will also work, but is problematic if
$var might contain escape characters).