When I've seen this done effectively, the engineer never outright refuses to do things the way their manager says. Instead, they take responsibility for educating their manager, in a way that the manager can understand and without threatening their ego. So if the manager says "Just do it like this", your response should be "That won't work because X, Y, and Z. However, I could do it like this, and it will have these costs and benefits and take me this long, and that's why I believe this is a superior course of action." At all points the decision is still up to the manager, but the senior engineer has brought enough data and experience to bear that they can convince their manager that it was a good idea to begin with.