Yes, this is possible to fix by yourself. One method we would suggest is to remove the roof lining of your car and purchase spray-on fabric glue, which will bond the material back to the bare ceiling or ceiling liner correctly.
If the current ceiling liner is soiled, stained or dirty, it may be worth purchasing new fabric whilst you carry out the repair. Although, this can be any type of fabric, it would be recommended that you use fabric for the purpose of lining car ceilings.
This would be a fairly cheap fix, but depending on the quality of the glue depends on how permanent a fix this would be. Also, depending on the age of your car, you may have a ceiling liner with the fabric attached to it. If this is the case, it may be easier to go to a scrap yard and pick up a second-hand ceiling liner that is not sagging, complete with the fabric attached, and completely replace your pre-existing ceiling fabric.
Another suggestion, which might prove more successful and aid in doing this repair would be to purchase a Haynes Manual suited to your car. Haynes produces a wide variety of manuals that cater for the majority of both classic and modern cars from simple fixes to more complex maintenance.
If it is a classic car or aged fifteen years or above, you will usually find specific owner group web forums on the Internet with communities of car owners that are usually happy to help with common problems you may face. If you are not fazed by the aesthetics of your car and you have a foam-backed ceiling, you can always just use a household staple gun to secure the fabric back into place.