Yes, she could have set the house-elves free, provided the house-elves wanted to own the clothes.
How do I know this? Hermione is one of the most-versed Hogwarts students, and she has read up on magical law, and House-elves are her hobby. It is inconceivable that Hermione would think that her hats would make the house-elves go free if it were not the case.
It's also implied in Order of the Phoenix, though its quite likely that Ron would not know the relevant laws:
‘No problem,’ said Ron. ‘Who’s that for,
anyway?’ he added, nodding at the neatly
wrapped present she was carrying.
‘Kreacher,’ said Hermione brightly.
‘It had better not be clothes!’ Ron warned
her. ‘You know what Sirius said: Kreacher
knows too much, we can’t set him free!’
So with that said, let us analyze the only time in the books where we see a house-elf getting free:
COS Ch. 18:
Harry grabbed the diary and dashed out of the office. He could
hear Dobby’s squeals of pain receding around the corner. Quickly,
wondering if this plan could possibly work, Harry took off one of
his shoes, pulled off his slimy, filthy sock, and stuffed the diary into
it. Then he ran down the dark corridor.
He caught up with them at the top of the stairs.
“Mr. Malfoy,” he gasped, skidding to a halt, “I’ve got something
for you —”
And he forced the smelly sock into Lucius Malfoy’s hand.
“What the — ?”
Mr. Malfoy ripped the sock off the diary, threw it aside, then
looked furiously from the ruined book to Harry.
“You’ll meet the same sticky end as your parents one of these
days, Harry Potter,” he said softly. “They were meddlesome fools,
He turned to go.
“Come, Dobby. I said, come.”
But Dobby didn’t move. He was holding up Harry’s disgusting,
slimy sock, and looking at it as though it were a priceless treasure.
“Master has given a sock,” said the elf in wonderment. “Master
gave it to Dobby.”
Here the sock clearly belonged to Harry, and was never owned by Malfoy, and wasn't even given to Dobby intentionally! Yet, even with all that, Dobby still goes free!
We also see that House-elves can handle clothes of their masters when their masters still own their clothes:
DH Ch. 12
Nothing in the room, however, was more dramatically different than the house-elf who now came hurrying toward Harry, dressed in a snowy-white towel, his ear hair as clean and fluffy as cotton wool, Regulus’s locket bouncing on his thin chest. “Shoes off, if you please, Master Harry, and hands washed before dinner,”croaked Kreacher, seizing the Invisibility Cloak and slouching off to hang it on a hook on the wall, beside a number of old-fashioned robes that had been freshly laundered.
Also: (COS Ch. 3)
"Yeah, Mum's always wishing we had a house-elf to do the ironing," said George.
Therefore we see that a house-elves freedom is not dependent on touching or receiving clothes, but rather on ownership of clothes.
This point is further proven in the books where the sign of a house-elf is a disgusting wardrobe:
COS Ch. 2:
Harry noticed that it was
wearing what looked like an old pillowcase, with rips for arm- and
Also (Ch. 21)
He blew his nose on a corner of the filthy pillowcase he wore,
looking so pathetic that Harry felt his anger ebb away in spite of
“Why d’you wear that thing, Dobby?” he asked curiously.
“This, sir?” said Dobby, plucking at the pillowcase. “ ’Tis a mark
of the house-elf’s enslavement, sir.
OOP Ch. 6:
George made to shut the door to drown the
noise, but before he could do so, a house-elf edged into the room.
Except for the filthy rag tied like a loincloth around its middle, it
was completely naked.
And Dobby takes pride in his wardrobe - or more accurately the fact that he can own clothes: (Again notice the emphasis on the ownership of clothes)
GOF Ch. 21:
When Dobby had worked for the Malfoys, he had always worn
the same filthy old pillowcase. Now, however, he was wearing the
strangest assortment of garments Harry had ever seen; he had done
an even worse job of dressing himself than the wizards at the World
Cup. He was wearing a tea cozy for a hat, on which he had pinned
a number of bright badges; a tie patterned with horseshoes over a
bare chest, a pair of what looked like children’s soccer shorts, and
odd socks. One of these, Harry saw, was the black one Harry had
removed from his own foot and tricked Mr. Malfoy into giving
Dobby, thereby setting Dobby free. The other was covered in pink
and orange stripes.
From all these quotes we see that handling clothes isn't what sets a house-elf free, it is OWNERSHIP of clothes.
Thus when Harry relinquished ownership of his sock and it was given to Dobby, Dobby went free even though Malfoy never owned the sock.
And thus, if Hermione relinquished ownership of the hats, if a house-elf so desired to own one of them, he would go free.
So why do more house-elves not go free?
Because a house-elf cannot go against his masters wishes, and if the master has commanded them not to receive clothes from anyone else, they cannot take possession of clothes until the master presents them with clothes.
This is also how a master can free a house-elf against his will (a la Mr. Crouch) by commanding them to take clothes, which a house-elf is required to do, even if it doesn't want to own the clothes (a la Winky).
So how could Hermione free the house-elves in Gryffindor's house? Because Dumbledore never made such a command to the house-elves that they were forbidden to own clothes, because it wouldn't bother him if they went free. Thus, any house-elf in Hogwarts could set themselves free by availing themselves of Hermione's hats.
So why didn't they? Because ownership of clothes and freedom is insulting to most house-elves:
None of them will clean Gryffindor Tower any more, not with the hats and socks hidden everywhere, they finds them insulting, sir. Dobby does it all himself, sir.