A hacking cough simply means she is experiencing airway irritation.
A cough can be related to heart disease, including heartworm, lung disease secondary to a viral, bacterial, fungal or parasitic infection or tracheal irritation due to a bacterial, viral or fungal infection, or a mass in the chest.
In a young dog infectious disease is by far the most common cause. Of those kennel cough or infectious tracheobronchitis is one of the most common causes. Because we know that she hasn't been exposed to other dogs, this seems to happen more at rest, and this has been lingering for a month on and off contagious diseases seem less likely. If this were contagious it seems your other pups would be coughing too, and they aren't. Kennel cough seems unlikely.
If she has significant tartar and gum disease that can lead to airway irritation and a secondary cough.
Heartworm is definitely possible.
Since she doesn't seem to cough with exercise or excitement and you don't note a loss in exercise tolerance heart disease or tracheal collapse both seem unlikely.
Lungworm is possible, especially since she was a stray.
A mass in the chest is possible too, and when she lays down that causes more chest compression and would predispose her to cough.
At this point from what you have told me I am concerned about heartworm disease, a possible lungworm infection, inflammation due to dental and gum disease, or a mass in her chest.
If she is very overweight then we can see some airway collapse when they lay down and rest (much like people that snore or have some sleep apnea). But I would expect her to have some difficulty with exercise too.
At this point she should see her veterinarian for an examination, heartworm and lungworm testing (take a fresh stool for lungworms, they draw blood for heartworm), and probably a chest radiograph.
In the meantime make sure she gets plenty of fluids. The better hydrated she is the better she will feel and the thinner her respiratory secretions will be.
You can take her into the bathroom with you when you take a hot bath or shower so she can breathe the steam which is soothing to her airways and thins mucous, making it easier for her to breathe. You can also use a humidifier in the room she sleeps in.
If the cough is very bad and she cannot sleep you can use human cough/cold medications with Guaifenesin (an expectorant) and Dextromethorphan (a cough suppressant) only such as Benylin or Robitussin DM can help. Give 1 teaspoon per 20 to 25 pounds every 6 to 8 hours.
If she has evidence of lots of tartar and gum disease brushing her teeth and using an antibacterial oral rinse like CET oral rinse will help keep bacteria levels down.
Best of luck with your girl, please let me know if you have any further questions.