Pawn to F6 is not a good move. Usually just take the pawn on d4 or defend with d6
How to avoid this early check-mate

That's the Scotch if you take the d4 pawn. You should take the d4 pawn with your e5pawn, not defend it with a pawn on f6. When the pawn is recaptured with their knight, don't take the knight with your knight, which would give them a strong center and kill your development. Instead bring your bishop out to c5 to point at the knight. He will probably retreat his knight to b3 to threaten your bishop, at which point you can retreat your bishop to b6 and continue play.
This can be understood as a variation on the Daimano Defense, which is usually not good for black. Look up Daimano and see what I mean.

In a nutshell, pawn to f6 was the mistake. Engine might say it's OK but as a general rule, you don't want to be pushing the F pawn in the opening, it can (and in this case did) leave you vulnerable to queen-check tactics.
That is the Scotch opening, the third most popular opening after 1. e4 e5 2. Nf3 Nf6 so you will have to get used to it. The pawn should be captured (3. ... exd4), there are no other good moves. There are some gambit lines after this, but the most common one is 4. Nxd4, whereafter Black plays either 4. ... Bc5 (I play this myself) or 4. ... Nf6. Besides 5. Nb3 after 4. ... Bc5 there is 5. Be3, where the theory continuation is 5. ... Qf6 (one of the rare cases, where you should bring the queen out early) 6. c3 (the idea was to take this square from the knight and hinder White's development) or 5. Nxc6 Qf6 (threatening Qxf2#) and depending on what White does, you can take the knight (or checkmate) on the next move. After 4. ... Nf6 White plays either 5. Nc3 or 5. Nxc6 bxc6 6. e5. Some of the lines in the Scotch are sharp, so try to look at all threats (both your and your opponents), when you face this next time (or start playing it yourself).
A good thing to remember is that you don't want to allow white a center with pawns on both e4 and d4. When white plays a move that establishes that, you want to be in a position to destroy it immediately. Usually by taking one of both pawns (when white can't recapture with another pawn). So here after exd4, you've destroyed the e4-d4 center, making it a good move.
Don't be too afraid of checkmates in the early game. The classic weak square in the opening is f7. You want to develop as fast as you can, so that you can castle as early as possible. Castling will defend that f7 square.
Moving the pawn to f6, makes the h5-e8 diagonal even weaker than it already was. And immediately there are tricks white can take advantage of. For example: 1. e4, e5; 2. Nf3, f6?? 3. Nxe5!, fxe5; 4. Qh5+ and now black can't play ...g6, cause white wins the rook with Qxe5+, but 4. ... Ke7 is also awful cause white will get a killing attack.
Incidentally, if you do feel scared about getting checkmated, try playing 1. e4, c5. There are no really early checkmate threats in the Sicilian and if you stick to normal ideas, like fast development (and not allowing white the e4 and d4 center), it's easy enough to play without having to learn anything about it.
Is pawn to d6 a viable option. Seems to be
Not really. White could take away your castling privileges after 4. dxe5, dxe5; 5. Qxd8+, as 5. ... Nxd8 would drop the e5 pawn.

Is pawn to d6 a viable option. Seems to be
Not really. White could take away your castling privileges after 4. dxe5, dxe5; 5. Qxd8+, as 5. ... Nxd8 would drop the e5 pawn.
Yeah, played it thru after I posted. Pawn takes d4 is the only real move

Is pawn to d6 a viable option. Seems to be
Not really. White could take away your castling privileges after 4. dxe5, dxe5; 5. Qxd8+, as 5. ... Nxd8 would drop the e5 pawn.
Losing castling priveledges is no big deal once the Queens are off.
How is White going to exploit it?

I think the opening poster got confused. In the last diagram, Black plays Ng6 and is winning. Black is up a piece after white sacrificed a knight for nothing.
Both sides played quite a few terrible moves in this short game.

I found the game. So instead of winning with Ng6, black chose to get mated in 1 move. Fascinating.
https://www.chess.com/analysis/game/live/12134842073?tab=analysis
Is pawn to d6 a viable option. Seems to be
Not really. White could take away your castling privileges after 4. dxe5, dxe5; 5. Qxd8+, as 5. ... Nxd8 would drop the e5 pawn.
Losing castling priveledges is no big deal once the Queens are off.
How is White going to exploit it?
I agree that it might not matter much in this position. However, that would be a discussion for 2300-players. There are also plenty of positions where it would not be optimal to lose castling rights, even with the queens off. And in general it's not a good idea for beginners to think that losing the castling rights is a good idea. When they get stronger, the exceptions will come. So, for beginners ...d6 is not a good move to think of playing. For us, it might not be that losing castling rights is so dramatic, but there might be other reasons why ...d6 is not optimal, which quite clearly is still the case.

Yeah I guess the problem with 3…d6 is that White has a number of options, clearly none of which are winning but all slightly passive for Black. 4.Bb5 gives black a Steinitz Lopez. 4.d5 followed by c4 is going to lead to some kind of Nimzowitsch where Black would normally want to have …Bc5 or …Bb4 options. Taking on e5 is going to be slightly more pleasant for white, as is even a move like 4.c3
So 3…d6 is probably just a bit ‘sad’ but obviously far preferable to 3…f6 which is fundamentally weakening.
I think the opening poster got confused. In the last diagram, Black plays Ng6 and is winning. Black is up a piece after white sacrificed a knight for nothing.
Both sides played quite a few terrible moves in this short game.
In game I didn't play G6, it was only when I was replaying it to see what I could've done that I realised I could've stopped the check-mate that way. However I was still interested in how I could've stopped it even getting that far. As for terrible play, I've only been playing since February so there will be plenty of that for a while yet.
I've got a defence against some of the early check-mates but I was caight out on this occasion and I'm not sure how I should avoid it and what it is I played badly. Any advice would be appreciated.
So this was the opening 4 moves
At this point I was caight up in defending the pawn on E5 and wondered if I should have gone for the exchanges rather than bringing my pawn out to F3.
Anyway, after that it went as follows:
And finally:
Other than moving my Knight to G6 is there anything I should've done before this to avoid getting into this spot?