Deciding FO-rewritability of Regular Languages and Ontology-Mediated Queries in Linear Temporal Logic