We claim that the answer is all multiples of $3.$
For $3|n,$ it's easy to see that it is possible. For $3 \nmid n,$ we will define a coordinate system where the top-left corner of the figure is $(0, 0)$ and every time we move right the $x-$coordinate increases by $1,$ and every time we move down the $y-$coordinate increases by $1.$
For $3 | n-2,$ we can just simply color every square with the color $x + y$ (mod $3$). Since every $1 \times 3$ or $3 \times 1$ contains an equal number of squares of each color, we attain a contradiction.
For $3 | n-1,$ we will color a square with color $xy$ (mod $3$). Then, it's clear that every $1 \times 3$ or $3 \times 1$ contains either one square of each color or $3$ squares all of color $3.$ In any case, each square contains the same number of each color modulo $3,$ and so the number of $1$'s, $2$'s, and $3$'s should all be congruent to each other modulo $3.$ However, it's easy seen that this is not the case, contradiction.
$\square$