The jury is still out and it will depend on numerous facts: local laws (many tbd), ToS, court rulings (tbd), does the result infringe on existing IP, is the writing copyrighted or part of a patent... In the US, iirc, patents by AI are denied.
tl;dr, no one really knows yet and it will change with time