A couple of immediate problems:
<- is used in list comprehensions. See https://www.erlang.org/doc/programming_examples/list_comprehensions.html or https://learnyousomeerlang.com/starting-out-for-real#list-comprehensions.
Assignment (matching, actually) works the same in a module:
[H | T] = L,
% ...do something with H and T...
Next:
[Head2 | Tail2 ] <- [List],
This isn't doing what you want either, even if we fix the <-. You've wrapped your list in another list, so if you started with List = [1, 2, 3], you'll actually be doing [Head2 | Tail2] = [[1, 2, 3]], and you'll end up with Head2 = [1, 2, 3] and Tail2 = [].
Outside the shell, you must put your Erlang code in a module, so you'll end up with something like this (the module name must match the filename, so my_module.erl):
-module(my_module).
% ...
In your example code, I've corrected the above two problems, which leaves us with:
f6(List) ->
[Head2 | Tail2 ] = List,
Head2.
Tail2.
This still won't work, because the dot (.) means the end of a function. So that Tail2. is just hanging around, causing a syntax error.
If you want to sum three numbers in a list, the simplest option is this:
-module(my_module).
f6([A, B, C]) ->
A + B + C.
This uses matching in the function header. It requires a three-element list, and it matches it such that each of A, B and C takes one of the elements. You can then add them.
It's not very flexible. What you probably wanted was recursion:
% don't do this, though; read on.
sum([H | T]) ->
H + sum(T);
sum([]) ->
0.
But that's going to blow the stack, because it's not tail-recursive. What you actually want is this:
sum(List) ->
sum(List, 0).
sum([], Acc) ->
Result;
sum([Elt | Rest], Acc) ->
sum(Rest, Acc + Elt).
This uses an accumulator with tail-recursion to add the values in the list.
This could be re-written as follows (taken directly from the docs at https://www.erlang.org/doc/man/lists.html#foldl-3:
sum(List) -> lists:foldl(fun(X, Sum) -> X + Sum end, 0, List).
But, if you really wanted the short version, there's already lists:sum(List). See https://www.erlang.org/doc/man/lists.html#sum-1