Why ALTER DATABASE .. MODIFY NAME reports an error while succeeding at the same time?
One possibility is that there's a DDL trigger that fires for ALTER DATABASE, and that trigger code try to refer to the (now old) database name.