If you're working with machine learning, I'd think it'd be obvious you can model ethics almost trivially. Let's interpret your input-->output as situation-->action, i.e., some description of an input situation to some description of an output action (and these descriptions can be Godel-numbered ascii strings, or even byte-by-byte Godel-numbered gif images, so we're never talking about anything beyond integers-->integers computable functions).
Then an AI has some already-determined method of choosing the optimal action-description for any given situation-description (within its domain of recognizable situations, e.g., maybe situations denoted by a language specified by some BNF grammar). So let's write AI:situation-->action for that function, which you're saying is "goal-oriented".
Well, we can just weight each possible (situation,action) pair with an "ethical function", say a real number in [0,1]. Then the ethically-weighted AI function's new goal is to pick the optimal action after applying those weights.
Now, you might argue we've just imposed our own ad hoc weights. And, indeed, the AI has no consciousness/awareness of any morality underlying its ethically weighted goals. But it might be able to train itself. For example, suppose the domain of situations is a poset where "S1 weaker-than S2" means S2 is the better situation (e.g., the little train-track dilemma, S2="flip a switch and kill one man" or S1="do nothing and five men die"). Then (omitting some crucial steps) the AI function can adjust its initial weights after observing/monitoring the effects of its situation-->action function.
So is that "ethics"? Like I said, no consciousness -- even a dog choosing not to pee on the carpet is self-aware of its choice, and denying itself the goal of immediately relieving itself in favor of the more heavily-weighted goal of pleasing you. So if "ethics" necessarily entails self-denial in favor of a "higher" purpose, then self-awareness is also necessary, and AI doesn't have that. But if "ethics" is "doing the right thing", period, then no problem for AI.