You are correct in suspecting that this firm produces no added value, but this does not contradict your definitions.
We sum up the cost of salaries and retained earnings of all firms in the economy
[...]
[a firm] produces no products, and its only expense is the CEO's salary which is $1 million dollars per year.
salaries |
retained earnings |
sum |
$+$ 1 million |
$-$ 1 million |
0 million |
EDIT:
user161005 pointed out that I did not answer the question in the title. Unprofitable companies can increase GDP. In the above example, if, due to some amount of production, the retained earnings were only −0.5 million dollars, the company would still operate at a loss, but the net (direct) effect on GDP would be positive.
salaries |
retained earnings |
sum |
$+$ 1 million |
$-$ 0.5 million |
0.5 million |
GDP is a problematic measure in many ways. The second example only shows us that GDP is higher if the company exists and employs these people than if the company did not exist and these people were unemployed. This begs the question: Is the labor in this example really "worth" 1 million dollars? (Is this a market value?) If it is, then if the company were to close AND the labor would be reallocated via the job market to other companies earning a similar salary, we would get an increase in GDP.