I can tell you what happened with my A3, the light was not coming on much, not setting off the alarm but bugged me so i looked into it.
There is a plug which goes into the rear lock(in the bootlid) which signals if its open or closed. This could be loose or bad contact... Or could be a faulty lock, on my A3 it is a closed unit so would have to be fully replaced but i seem to have fixed it with copius amounts of wd40 into the lock and connector to prevent rust mmessing up the connections..
To get to this is easy, the tailgate plastic cover pulls off (there are some screws in the grab handle to undo first). I cant remember on the A6 if there are any more screws i havent done one in ages but they should be obvious.
Once your in you should be able to see whats going on and test a few things out.
FYI Also in my infinite wisdom i tried slamming it shut, but i didnt realise i pushed the mech it to the locked position before, this pushed the metal bar which it locks to down meaning my boot wouldnt shut, so had to spend a while stripping it down and fixing that bar to where its meant to be lol (that bar is slightly movable once loose.