Why couldn't I put 'ikke' at the end?
Adverbs (like ikke) usually go right after the inflected verb.
You can also say "batteriet virker ikke" but i dont know why it doesnt mark it correct
Your sentence misses the future aspect of the English translation. Like, "If you put this battery in now, it will not work." You just say "The battery (which I'm trying to use right now) does not work."