There may be twelve - he Obliviated twelve people for his books.
In the Pottermore writing by JKR on Gilderoy Lockhart, it’s stated that he modified the memory of a dozen wizards and witches so he could take credit for what they did, and that he came back with a new book ready for publication after each ‘adventure’ on what he supposedly did.
The truth was that Lockhart had found his true calling at last. He had never been a bad wizard, only a lazy one, and he had decided to hone his talents in one direction: Memory Charms. By perfecting this tricky spell, he had succeeded in modifying the recollections of a dozen highly accomplished and courageous witches and wizards, allowing him to take credit for their daring exploits, returning to Britain at the end of each ‘adventure’ with a new book ready for publication which retold ‘his’ feats of bravery with a wealth of invented detail.
- Gilderoy Lockhart (Pottermore)
That suggests, presuming each individual wizard’s exploits were turned into a new book (which seems likely enough), that he’d have written at least twelve books in all.
Lockhart wrote at least nine books that were named in total.
In total, there are at least nine books that Lockhart wrote. Lockhart wrote a guide to exterminating household pests, which Mrs. Weasley has in her house.
“Harry looked at the cover of Mrs Weasley’s book. Written across it in fancy gold letters were the words: Gilderoy Lockhart’s Guide to Household Pests.”
- Harry Potter and the Chamber of Secrets, Chapter 3 (The Burrow)
There were seven of Lockhart’s books on the Hogwarts required book list as necessary textbooks for Defense Against the Dark Arts classes. The book list doesn’t require Hogwarts students to buy all of Lockhart’s books, as there are at least two of his books that we know of that are not on it.
“Break with a Banshee by Gilderoy Lockhart
Gadding with Ghouls by Gilderoy Lockhart
Holidays with Hags by Gilderoy Lockhart
Travels with Trolls by Gilderoy Lockhart
Voyages with Vampires by Gilderoy Lockhart
Wanderings with Werewolves by Gilderoy Lockhart
Year with the Yeti by Gilderoy Lockhart”
- Harry Potter and the Chamber of Secrets, Chapter 4 (At Flourish and Blotts)
He also wrote his autobiography, Magical Me, which he was selling in Flourish and Blotts.
“GILDEROY LOCKHART
will be signing copies of his autobiography
MAGICAL ME”
- Harry Potter and the Chamber of Secrets, Chapter 4 (At Flourish and Blotts)
There can’t be that many additional books than the ones mentioned by name, since his entire bibliography fits in a cauldron.
“The crowd cheered and clapped and Harry found himself being presented with the entire works of Gilderoy Lockhart. Staggering slightly under their weight, he managed to make his way out of the limelight to the edge of the room, where Ginny was standing next to her new cauldron.
‘You have these,’ Harry mumbled to her, tipping the books into the cauldron. ‘I’ll buy my own –”
- Harry Potter and the Chamber of Secrets, Chapter 4 (At Flourish and Blotts)
There may be a few not mentioned in the books, as it’s possible more than nine books fit in a cauldron, and Harry passed them all off on
Ginny quickly, so we don’t see them. In addition, the writing on Pottermore about Lockhart suggests there might be twelve.