Yes, but …
It's not that big of an agreement. As NautArch points out,
With respect to Combat XP, the DMG simply says:
Each monster has an XP value based on its level of challenge. When the adventurers defeat one or more monsters, usually killing them, defeating them or capturing them, divide the total XP value of the monsters evenly among them.
Technically, you're just killing him, let him reform and then kill him again … but did you really kill him?
If the DM determines that this is a valid "XP factory" and that killing it is the same as defeating it, you will have to understand the cost of that factory.
A Flameskull has a challenge rating of 4 and is worth 1,100 XP. Assuming you have a group of 4 players in level 4, each time you kill the Skull, each of you gains 275 XP. 275 XP per hour at the cost of fighting a creature that can cast a large number of spells an unlimited number of times is not much. With the minimum minimum of 2,700 XP required to be level 4, it would take 14 hours and 14 encounters with this skull to reach level 5 and another 28 hours and 28 encounters to reach level 6.
Think of the cost of fighting a creature with 40 HP, 13 BC, with multiple resistances, immunities and condition immunities. It's not as easy as killing him instantly, because if you can not kill him instantly, he can throw a fireball every time he resuscitated. Or, it can flee, attack or, otherwise, lengthen the encounter to become more deadly.
In general, the characters are not destined to have 14 medium challenge matches a day and are not equipped to fight so many times without resting a lot. It is not a great feat, it is more a strategy with a great cost. And if he wants to continue fighting, he can never stop to rest a lot or leave him alone for more than an hour because, in all probability, he will flee or do something to stop his difficult strategy.)
This does not say anything about whether your DM really allows you to do this in a vacuum or do it at all. But yes, if you want to make a very slow XP grinder, you can do it.