Is this unethical?
Maybe, but not necessarily.
Firstly, it is you that is being interviewed for this job, not your friend. Unless your friend is going to be willing to do your work for you when you get the job, you should present your work without his input. The company is trying to assess you, not someone else.
However, unless the instructions with the task specifically state that you must complete it alone, you are free to assume that you are allowed to complete it in whatever way you wish. This is, after all, supposed to be the point of a complete-at-home task: "realism" and freedom. That means using Google, Stack Overflow, and even the input of others are all valid options. Read the instructions closely and follow them accordingly.
(Personally I think a company asking a candidate to complete some task on their own time are unfairly abusing that candidate's good nature anyway. But those companies that do choose to do this, must provide clear instructions on how the task is to be approached and whether there are any restrictions on time or resources that the candidate should limit themselves to. If they do not, any approach is completely fair game).
Indeed, it is perfectly normal to ask a friend to review one's CV or covering letter. This is not quite the same situation as that, but it could be argued that it is similar.
In summary: follow the instructions with the task. If there are no instructions, you may do as you wish. But you must be able to justify your hiring to this position, whether your friend helps or not, so you may wish to consider making a point of doing it alone.