You did not specify what kind of attack, and that actually matters a bit in the end.
Let's assume that the Rage ability is referring to the Attack action, which means that a Barbarian may make a melee or ranged attack against a hostile creature in order to sustain Rage.
Additionally, attacks are defined very broadly: "If there’s ever any question whether something you’re doing counts as an Attack, the rule is simple: if you’re Making an Attack roll, you’re Making an Attack"
A Barbarian who tries to attack an illusion has made an attack, since they made an attack roll.
The only question now is whether or not targeting the illusion counts as targeting a hostile creature.
By RAW, a grapple or shove is considered a special melee attack, which means that a Barb can use either to sustain their rage.
Additionally, these can only be targeted on creatures, and in fact require a specific Size value to even attempt.
Therefore, if you, as the DM, allow your Barbarian to target an illusion with a grapple or shove, then you have already ruled that it counts as a creature for the purpose of targeting. By RAW, hostile is an attribute of creatures, and is applied for a creature which "opposes the adventurers and their goals but doesn't necessarily attack them on sight." The illusion was placed in passive opposition to the adventurers, so would count as hostile as long as it counts as a creature for the purpose of targeting. There could be another question here about whether or not an unconscious or non-sentient creature can be considered hostile, but whatever. You've already ruled that it's a creature for the purpose of targeting, so the Barbarian's Rage continues.
In almost any other circumstance, you probably haven't pre-ruled any particular way. But just bear in mind that if you allow the illusion to be targeted by any attack, then it's an object, creature, or location.
My suggestion is to pick creature, since picking object means that it can be targeted by Shatter, and picking location is the same as saying that a location can occupy a location...