This is not an either/or situation. In a successful agile implementation, all parties collaborate on what product to build and how to validate that it's fit for purpose.
If instead you're positing a non-collaborative environment where product decisions are set by diktat rather than through active collaboration between the value consumer and the Scrum Team, then this isn't really a question about Scrum. Instead, it's a much more basic one about communication and career management.
Analysis & Recommendations
What can, and should, a Product Owner / Product Manager do if the CEO has mandated that the team builds something which the Product Owner feels is not in the best interests of the customer?
The Product Owner generally acts as the primary liaison with the customer (although high-performing agile teams often interface directly with customers), and functions as the "voice of the customer" in determining value when structuring the Product Backlog. However, the customer is not the only stakeholder: the CEO, CFO, and other internal stakeholders should also have input.
Pragmatically, a senior executive can certainly influence or override the decisions of a Product Owner either through diktat or via the budgeting process. However, doing so is generally a sign of one or more of the following:
- Lack of trust in the market savvy or prioritization skills of the Product Owner.
- Non-agile micromanagement at the top of the organization.
- Lack of faith in the collaboration process with the customer(s).
- Insufficient buy-in for the product/project management framework.
- Distrust (justified or not) of the team building or delivering the product.
With that said, the Product Owner's primary accountability is to be the sole arbiter of the Product Backlog. So, if senior management disagrees with the contents or priorities of the backlog, the Product Owner can:
- Influence the stakeholders to buy into the strategic vision for the product.
- Be influenced by the stakeholders to refactor the backlog, or even re-envision the product and the backlog's contents.
However, in a thoroughly non-collaborative, command-and-control environment where the Product Owner is neither empowered to fulfill the role nor able to successfully collaborate on the product vision, then the Scrum values of honesty and communication come into play. A Product Owner who truly doesn't believe in the product vision, or who is not truly empowered to fulfill the accountabilities of the Product Owner role, must have the integrity and courage to point that out to the Scrum Team and senior leadership.
Ultimately, an organization's leadership bears full responsibility for the outcome of any project. If the Product Owner has done the job of providing solid market analysis and product vision to senior leadership, the PO then needs to either align with leadership's vision or have the courage to walk away.
In practice, if you find yourself having to ask how to resolve a major disconnect with senior leadership, the communication failures and lack of collaboration may already be too far along to salvage. In that case, dust of your resume and prepare to move on, whether before or after the death march you're predicting. Otherwise, dust off your interpersonal skills and find a collaborative path through the disconnect that doesn't leave the Product Owner in the position of being responsible for the results of a product they lack authority to influence.
Responsibility without authority is a common problem in project management, and is generally a red flag. If you're sure that's what you're dealing with, prepare to exit stage left.