Q: If a literary work is in the #PublicDomain or is licensed under an #Attribution and/or #ShareAlike license (like #CCBy and #CCBySA), is it still #Fanfiction?
A: No.
Explanation:
You see, in the strictest sense, a fanfiction is an unlicensed/unauthorised derivate of a Copyrighted work.
Since the Public Domain, and the Attribution and ShareAlike licenses (provided you follow the license terms), allow for anyone to create a derivative work, then any and all works based on it are not fan fiction.